java - 填充 ListView 时 LinearLayout 为 'pushed'

标签 java android listview android-linearlayout

<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/

相关文章:

java - java中上下文切换具体案例

java - JPA实体管理器从实体createQuery,不同的包但名称相同

Android ScrollView 渲染 ImageView 非常慢

android - 更新到 3.0 后 Gradle 构建失败

java - 如何在构建时使用 Maven 正确增强类?开放式JPA

android - 如何通过单击从 SQLite 中的列中删除所有值?

java - 在 ListView 中隐藏和显示列表项无法正常工作

java - Android:上下文菜单不显示 ListView 的成员由 LinearLayout 定义?

android - 当在项目上激活触摸监听器时单击不起作用

java - Maven 无法识别本地存储库中的 Jar