作者热门文章
- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我试过这段代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ListView
android:id="@+id/List1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<ListView
android:id="@+id/List2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<ListView
android:id="@+id/List3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<ListView
android:id="@+id/List4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
</LinearLayout>
没有成功。这行得通,但我不想划分 x
所有列表的屏幕,我想扩展 width
每个列表的列表,并可以在 x
上滚动轴 ...有谁知道我是否可以做到这一点?
最佳答案
这是可能的。在您的情况下,它不起作用,因为 android:layout_width
设置为 fill_parent
,因此第一个布局将占用所有可用空间。尝试为每个 ListView
提供 android:layout_weight="1"
。并删除不需要的内部 LinearLayouts
。
这对我有用:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ListView
android:id="@+id/List1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
<ListView
android:id="@+id/List2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1" />
</LinearLayout>
我刚刚获取了您的代码并删除了两个 ListView :
关于android - 如何将两个或多个 ListView 放在同一个布局上?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5106535/
我是一名优秀的程序员,十分优秀!