将首选项屏幕与android中的普通xml文件混合

时间:2015-03-20 15:02:29

标签: android xml

我是android的新手,所以请原谅我,如果这个问题太简单了。 我想创建一个xml文件,通过选中复选框来记住用户是否想要保持登录状态。这是示例布局(我刚刚使用了下图中的常规复选框)。 enter image description here

是否可以将PreferenceScreen与xml文件中的常规LinearLayout混合使用?如果有,你能告诉我结构吗?

我尝试过这样做,但是我收到了错误。

<LinearLayout
    android:layout_height="wrap_content"
    android:layout_width="fill_parent"
    android:orientation="horizontal"
    android:weightSum="2">

    <PreferenceScreen>
        <CheckBoxPreference
        android:defaultValue="false"
        android:key="checkbox"
        android:summary="remember me">
        </CheckBoxPreference>
    </PreferenceScreen>

    <TextView
    android:id="@+id/tvRegister"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="140dp"
    android:textSize="20dp"
    android:text="Not yet member?"
    android:layout_weight="1"
    android:textColor="#5F61D9" />

我希望它看起来就像上图。

0 个答案:

没有答案