有关显示设置的问题

时间:2019-04-19 08:40:55

标签: android androidx preferencescreen

我正在使用androidx库,并且有一些问题。如图所示,enter image description here在左侧有一个空白空间,我希望将控件附加到左侧边缘。同样在另一个应用程序中,使用其他库进行设置,首选项显示在控件标题下,是否有可能使用androidx显示首选项?提前感谢

fragment_settings.xml

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginStart="0dp"
    tools:context=".SettingsFragment">

</FrameLayout>

activity_settings.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".SettingsActivity">

    <fragment
        android:id="@+id/activity_settings"
        android:name="com.adc.settingsapp.SettingsFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

</LinearLayout>

pref_configuration.xml

<androidx.preference.PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">


    <PreferenceCategory
        app:key="pref_general_category"
        app:title="Notifications">

        <SwitchPreference
            android:defaultValue="true"
            android:key="pref_raccomandations_switch"
            android:summary="@string/pref_description_social_recommendations"
            android:title="@string/pref_title_social_recommendations" />

        <!-- NOTE: EditTextPreference accepts EditText attributes. -->
        <!-- NOTE: EditTextPreference's summary should be set to its value by the activity code. -->
        <EditTextPreference
            android:capitalize="words"
            android:defaultValue="John Smith"
            android:inputType="textCapWords"
            android:key="pref_display_name"
            android:maxLines="2"
            android:selectAllOnFocus="true"
            android:singleLine="false"
            android:title="Display Name" />

    </PreferenceCategory>

    <PreferenceCategory
        app:key="language_category"
        app:title="Language">

        <ListPreference
            android:defaultValue="English"
            android:entries="@array/pref_language"
            android:entryValues="@array/pref_language"
            android:key="pref_language"
            android:negativeButtonText="@null"
            android:positiveButtonText="@null"
            android:title="Language" />

    </PreferenceCategory>

    <PreferenceCategory
        app:key="pref_others_category"
        app:title="Others">

        <CheckBoxPreference
            android:key="pref_checkbox"
            android:title="Opt 1"
            android:summary="option 1"
            android:defaultValue="false"/>

    </PreferenceCategory>

</androidx.preference.PreferenceScreen>

0 个答案:

没有答案