android – 在首选项菜单中使用相对布局

我的应用程序中有首选项菜单.我使用的是
Android 1.6.我想在屏幕底部使用静态保存按钮.

我知道如何使用android进行相对布局:layout_alignParentBottom =“true”

    <Button
    android:id="@id/preferencesSaveButton"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="center_horizontal"
    android:layout_marginBottom="10dp"
    android:layout_marginLeft="20dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="10dp"
    android:padding="15dp"
    android:text="Save"
    android:textStyle="bold" />

我们可以在Relative Layout中使用偏好,还是有其他实用方法可以做到这一点?

最佳答案 您可以在选项卡式布局中使用首选项活动,这将是您查询的实用方法.选项卡式布局应具有相对布局..

在其中一个tabhost中,您可以通过意图使用首选项活动..看起来很酷.

我不认为你需要一个优先保存按钮..如果你有偏好活动,它会自动保存偏好并共享.

<?xml version="1.0" encoding="utf-8"?>

    <TabHost android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@android:id/tabhost"
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <RelativeLayout
  android:layout_height="fill_parent"
  android:layout_width="fill_parent">

  <FrameLayout
    android:id="@android:id/tabcontent"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@android:id/tabs"
    android:padding="5dp" />

  <TabWidget
    android:id="@android:id/tabs"
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" />
</RelativeLayout>
    </TabHost>
点赞