проблемы с отображением настроек - PullRequest
0 голосов
/ 19 апреля 2019

Я использую библиотеку 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>
...