在页面底部放置按钮

Place buttons at bottom of page

我无法将应用程序中的唯一按钮放置在屏幕右下角。代码可以在下面找到:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp" >

<ExpandableListView
    android:id="@+id/exp_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="#A4C739"
    android:dividerHeight="0.5dp"
    android:indicatorLeft="?android:attr/expandableListPreferredItemPaddingLeft" >

</ExpandableListView>

<Button
    android:id="@+id/btnDisplayMessage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/exp_list"
    android:layout_below="@+id/exp_list"
    android:layout_marginLeft="40dp"
    android:gravity="bottom"
    android:text="@string/next" />
</RelativeLayout>

这应该为您指明正确的方向:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:paddingLeft="16dp"
    android:paddingRight="16dp"
    android:paddingTop="16dp"
    android:paddingBottom="16dp">



    <Button
        android:id="@+id/btnDisplayMessage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_alignParentBottom="true"
        android:text="@string/next" />

    <ExpandableListView
        android:id="@+id/exp_list"
        android:layout_above="@id/btnDisplayMessage"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:divider="#A4C739"
        android:dividerHeight="0.5dp"
        android:indicatorLeft="?android:attr/expandableListPreferredItemPaddingLeft">

    </ExpandableListView>
</RelativeLayout>

试试这个

  <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
android:paddingBottom="16dp" >

<ExpandableListView
    android:id="@+id/exp_list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:divider="#A4C739"
    android:dividerHeight="0.5dp"
    android:layout_marginBottom="60dp"
    android:indicatorLeft="?android:attr/expandableListPreferredItemPaddingLeft" >

</ExpandableListView>

<Button
    android:id="@+id/btnDisplayMessage"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentRight="true"

    android:text="@string/next" />

</RelativeLayout>