android中的底部按钮栏

Tro*_*roj 20 android

我想知道如何在android中创建底栏按钮,

我读了一些关于这个UI解决方案的内容,是否有可以使用的控件?

Omr*_*mri 38

你可以在相对布局中做这样的事情

<LinearLayout android:id="@+id/footer" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:orientation="horizontal"
    android:layout_alignParentBottom="true" style="@android:style/ButtonBar">

    <Button android:id="@+id/saveButton" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight="1"
        android:text="@string/menu_done" />

    <Button android:id="@+id/cancelButton" android:layout_width="wrap_content"
        android:layout_height="wrap_content" android:layout_weight="1"
        android:text="@string/menu_cancel" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

  • 当你使用`layout_weight`作为按钮时,你应该将`layout_width`设置为0dp. (14认同)

小智 7

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
    <LinearLayout
     android:id="@+id/buttonBar"
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     style="@android:style/ButtonBar"
     android:gravity="center"
     >
          <TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="20sp"
          android:textStyle="bold"
          android:textColor="#FFFFFF"
          android:text="Button Bar"/>   
     </LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

从以下链接 底栏获取它