Android: How to maximize PreferenceFragment width (or get rid of margin)?

后端 未结 8 1061
误落风尘
误落风尘 2020-11-28 12:58

\"Android

\"FragmentsBC

相关标签:
8条回答
  • 2020-11-28 13:42

    The answers here didn't work for me. However, this one did:

    source: https://stackoverflow.com/a/53402144/9026710

    In your PreferenceScreen add this line:

    xmlns:app="http://schemas.android.com/apk/res-auto"
    

    add this line in PreferenceScreen and it's elements:

    app:iconSpaceReserved="false"
    

    Example:

    <?xml version="1.0" encoding="utf-8"?>
    <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
        app:iconSpaceReserved="false"
        xmlns:app="http://schemas.android.com/apk/res-auto">
        <CheckBoxPreference
            app:iconSpaceReserved="false"
            android:defaultValue="false"
            android:key="key1"
            android:title="title1" />
        <SwitchPreference
            app:iconSpaceReserved="false"
            android:defaultValue="false"
            android:key="@string/pref_wakeup"
            android:title="key2" />
    </PreferenceScreen>
    
    0 讨论(0)
  • 2020-11-28 13:43

    Another option is to set your own adapter. That way you have more flexibility and it's more robust against changes.

    See that other answer about custom header adapter

    0 讨论(0)
提交回复
热议问题