使用默认的xml属性复制Android Preference屏幕样式

时间:2014-01-17 10:41:59

标签: android xml user-interface

我已经研究了这个,但我无法在任何地方找到正确的答案......我正在努力让我的应用的“帮助”用户界面看起来与默认的Android默认“偏好”用户界面类似。

有关如何获取“首选项”屏幕使用的属性的任何想法(例如,textsize,textapparenceattribute等等)。

感谢您的帮助!

1 个答案:

答案 0 :(得分:1)

好吧,你可以下载Android SDK并查看所有Android默认布局所在的“/ sdk / platforms / android-xx / data / res / layout”。

以下是您可能感兴趣的文件名:

preference_category_holo.xml
preference_category.xml
preference_child_holo.xml
preference_child.xml
preference_dialog_edittext.xml
preference_header_item.xml
preference_holo.xml
preference_information_holo.xml
preference_information.xml
preference_list_content_single.xml
preference_list_content.xml
preference_list_fragment.xml
preferences.xml
preference_widget_checkbox.xml
preference_widget_seekbar.xml
preference_widget_switch.xml
preference.xml

以下是首选项列表XML的示例:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_height="match_parent"
    android:layout_width="match_parent">

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="0px"
        android:layout_weight="1">

        <LinearLayout
            android:id="@+id/headers"
            android:orientation="vertical"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

            <ListView android:id="@android:id/list"
                style="?attr/preferenceFragmentStyle"
                android:layout_width="match_parent"
                android:layout_height="0px"
                android:layout_weight="1"
                android:drawSelectorOnTop="false"
                android:scrollbarStyle="@integer/preference_fragment_scrollbarStyle"
                android:cacheColorHint="@android:color/transparent"
                android:listPreferredItemHeight="48dp"
                android:scrollbarAlwaysDrawVerticalTrack="true" />

            <FrameLayout android:id="@+id/list_footer"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0" />

        </LinearLayout>

    </LinearLayout>

    <RelativeLayout android:id="@+id/button_bar"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_weight="0"
        android:visibility="gone">

        <Button android:id="@+id/back_button"
            android:layout_width="150dip"
            android:layout_height="wrap_content"
            android:layout_margin="5dip"
            android:layout_alignParentLeft="true"
            android:text="@string/back_button_label"
        />
        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true">

            <Button android:id="@+id/skip_button"
                android:layout_width="150dip"
                android:layout_height="wrap_content"
                android:layout_margin="5dip"
                android:text="@string/skip_button_label"
                android:visibility="gone"
            />

            <Button android:id="@+id/next_button"
                android:layout_width="150dip"
                android:layout_height="wrap_content"
                android:layout_margin="5dip"
                android:text="@string/next_button_label"
            />
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>