Android: How to disable Reserved Icon Space in Preference Screen
Asked Answered
D

2

11

I have got a trouble with layout of Preference screen after updated SDK to version 28 (Android Pie). Each PreferenceScreen has a new padding on the left.

As I've checked, there is a method to set icon space as reserved in Preference class already.

android.support.v7.preference.Preference.setIconSpaceReserved(boolean iconSpaceReserved)

The method is good so far, but the problem is that it doesn't work with PreferenceCategory.

Does this mean that the left padding on PreferenceCategory is not a space for icon?

Dedrick answered 27/9, 2018 at 17:24 Comment(1)
I solved by a workaround with styles. It works with PreferenceCategory. https://mcmap.net/q/176921/-preferencefragmentcompat-has-padding-on-preferencecategory-that-i-can-39-t-get-rid-ofStomacher
H
9

Solved using app:iconSpaceReserved="false" in the preference xml (under each item).

    <PreferenceCategory
    android:title="Pro Settings"
    app:iconSpaceReserved="false"
    >

    <CheckBoxPreference
        android:defaultValue="false"
        android:key="plugin"
        android:title="@string/EnablePlugin"
        android:summary="@string/PluginDescription"
        android:id="@+id/Pref"
        app:iconSpaceReserved="false"
        />

</PreferenceCategory>
Hoye answered 17/3, 2020 at 13:24 Comment(0)
G
3

it is a bug and already solved. you need to wait for the update

https://issuetracker.google.com/issues/111662669

Grimaldi answered 5/10, 2018 at 7:12 Comment(1)
A fix has now been released in androidx.preference 1.1.0-alpha01. I guess this means it will never be released in the com.android.support track.Physicist

© 2022 - 2024 — McMap. All rights reserved.