Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/204.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 按钮不出现在我的布局中_Android_Android Layout - Fatal编程技术网

Android 按钮不出现在我的布局中

Android 按钮不出现在我的布局中,android,android-layout,Android,Android Layout,我想设置listview,并在屏幕底部设置一个按钮。但当我填写listView时,按钮不再出现。我不知道为什么。这里有人能帮我吗?将您的listview和按钮放在一个相对布局中。并将属性设置为alignparentbottom。即使listview已满且需要滚动,该按钮也将始终位于列表上方 希望这有帮助。使您的布局看起来像这样: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:an

我想设置listview,并在屏幕底部设置一个按钮。但当我填写listView时,按钮不再出现。我不知道为什么。这里有人能帮我吗?

将您的listview和按钮放在一个相对布局中。并将属性设置为
alignparentbottom
。即使listview已满且需要滚动,该按钮也将始终位于列表上方


希望这有帮助。

使您的布局看起来像这样:

        <?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"
    android:orientation="vertical" 
    style="@style/listbag">
     <LinearLayout  android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="1dp">
    <ListView
        android:id="@+id/groupListView"
        style="@style/listbag"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="100"
        android:listSelector="@drawable/list_selector1"
        android:background="@drawable/radius"  />
 </LinearLayout>
<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="1dp">
    <Button
        android:id="@+id/addfrendstogroupButton"
        android:layout_width="fill_parent"
        android:layout_height="42dp"
        android:text="Create new group" 
        android:textColor="@color/gray2"
        android:background="@drawable/button_indicator"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="1dp"
        android:layout_alignParentBottom="true"

        />
       </RelativeLayout>

          </LinearLayout>
<RelativeLayout>
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    <ListView>
        ....
    </ListView>
    <Button
        ....
        android:layout_alignParentBottom="true"
        .... />
</RelativeLayout>

android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”
....

我想在@iturki中添加这样做会更灵活:

        <?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"
    android:orientation="vertical" 
    style="@style/listbag">
     <LinearLayout  android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="1dp">
    <ListView
        android:id="@+id/groupListView"
        style="@style/listbag"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="100"
        android:listSelector="@drawable/list_selector1"
        android:background="@drawable/radius"  />
 </LinearLayout>
<RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="1dp">
    <Button
        android:id="@+id/addfrendstogroupButton"
        android:layout_width="fill_parent"
        android:layout_height="42dp"
        android:text="Create new group" 
        android:textColor="@color/gray2"
        android:background="@drawable/button_indicator"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginBottom="1dp"
        android:layout_alignParentBottom="true"

        />
       </RelativeLayout>

          </LinearLayout>
<RelativeLayout>
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    <ListView>
        ....
    </ListView>
    <Button
        ....
        android:layout_alignParentBottom="true"
        .... />
</RelativeLayout>

....
android:over=“@id/button”
....

否则,
按钮
将位于列表视图的顶部,从而隐藏列表视图的结尾。

你说的“填充列表视图”是什么意思?我想这就是我们想要的,我的意思是,对于另一个答案,
按钮
将隐藏
列表视图
的结尾。这是正确的。对于像我这样的初学者来说没有“>”。这个答案是从2011年开始的,现在是2020年,没有人应该使用RelativeLayout。如果您正在尝试以下操作,请使用ConstraintsLayout:)