【问题标题】:Layout with list带列表的布局
【发布时间】:2011-01-21 04:09:43
【问题描述】:

我有一个带有以下 layout-xml 的 listactivity

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="fill_parent"
    xmlns:myapp="http://schemas.android.com/apk/res/se.javalia.myDrinks"
    >
    <Button android:id="@+id/saveButton" 
        android:text="test test" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" />
    <ListView  
        android:id="@+id/android:list"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" />
    <TextView 
            android:id="@+id/android:empty"
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            android:text="@string/main_no_items" /> 
</LinearLayout>

现在,我想在列表上方添加一个按钮,该按钮在列表滚动时保持不变。 有可能吗?

提前致谢 罗兰

【问题讨论】:

    标签: android layout button listactivity


    【解决方案1】:

    绝对有可能,只需在 XML 中的 ListView 之前添加一个 Button 即可。如果您的 View 变得更加复杂,我会将您的 LinearLayout 更改为 RelativeLayout,然后您可以更轻松地定位元素。

    【讨论】:

      【解决方案2】:

      是的,只需在 ListView 上方添加一个按钮。

      【讨论】:

      • 如果只有那么简单的地方,它就行不通了。现在我只看到按钮,没有列表。
      【解决方案3】:

      在您的第一个 LinearLayout 中,您应该添加:android:orientation="vertical"

      【讨论】:

      • 宾果游戏。这是你的问题,罗兰。无论出于何种原因,默认方向都是水平的。
      猜你喜欢
      • 1970-01-01
      • 2013-11-27
      • 1970-01-01
      • 1970-01-01
      • 2021-06-06
      • 2013-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多