<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/buttonLayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1">
<Button
android:id="@+id/vehicleButton"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="Refresh"
android:onClick="getVehicles" />
<Button
android:id="@+id/logoutButton"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_weight="1"
android:text="Logout"
android:onClick="logout" />
</LinearLayout>
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
大家好,当上面的 ListView 只填充了几个项目时,我仍然可以看到按钮,但是,当 ListView 填充的项目超过屏幕可以显示的数量时,按钮似乎被“推”到了上面UI 和 不再可见,现在只有可滚动的 ListView 可见。
对于如何使按钮再次出现在较长的列表上,有什么想法吗?
谢谢
最佳答案
尝试将 ListView 包装在 LinearLayout 内。您正在向按钮添加权重以确保它们出现,但是当 ListView 呈现时,它似乎会导致这种情况。如果有帮助请告诉我。
<LinearLayout
android:layout_height="0"
android:layout_width="fill_parent"
android:layout_weight="0"
android:orientation="vertical">
<ListView
android:id="@+id/android:list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
关于java - 填充 ListView 时 LinearLayout 为 'pushed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13526703/