gpt4 book ai didi

android - 水平 ScrollView 内的水平线性布局

转载 作者:太空狗 更新时间:2023-10-29 15:47:06 25 4
gpt4 key购买 nike

布局.xml

 <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<HorizontalScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >

<LinearLayout
android:id="@+id/itemlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/itemlistbg"
android:gravity="center_vertical"
android:orientation="horizontal"/>

</HorizontalScrollView>

</LinearLayout>

我正在将子级动态添加到线性布局 id itemlist。如果项目太多,那么结果就可以了。但是如果列表中有 2 个项目,那么线性布局 itemlist 会在末尾留一个空格。 这只发生在大屏幕设备上

eclipse preview of xml

最佳答案

尝试像这样改变你的 ScrollView 。

<HorizontalScrollView
android:layout_width="fill_parent"
android:background="@drawable/itemlistbg"
android:layout_height="wrap_content" >

<LinearLayout
android:id="@+id/itemlist"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"/>

</HorizontalScrollView>

希望对您有所帮助。

关于android - 水平 ScrollView 内的水平线性布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17298746/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com