【问题标题】:Place buttons at bottom of page将按钮放在页面底部
【发布时间】:2015-03-11 06:57:46
【问题描述】:

我在将我的应用程序中唯一的按钮放置在屏幕右下角时遇到了问题。代码如下:

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

【问题讨论】:

    标签: android xml layout


    【解决方案1】:

    试试这个

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

    【讨论】:

    • 谢谢豪尔赫。排序:)
    【解决方案2】:

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

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

    【讨论】:

    • 当我运行应用程序时,我收到应用程序意外停止的错误。
    • 你必须比这更具体,可能会问一个新问题。
    猜你喜欢
    • 1970-01-01
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-27
    • 1970-01-01
    • 2021-02-07
    • 2014-04-21
    相关资源
    最近更新 更多