-
-
Save huhuang03/5911eb8f9c75736d9510d1813be3c608 to your computer and use it in GitHub Desktop.
Android: How to remove margin/padding in Preference Screen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/questions/18509369/android-how-to-remove-margin-padding-in-preference-screen | |
Simple working solution from here. | |
It works across all preferences without need write to all preferences app:iconSpaceReserved="false" | |
Create res/values-sw360dp/values-preference.xml: | |
<resources xmlns:tools="http://schemas.android.com/tools"> | |
<bool name="config_materialPreferenceIconSpaceReserved" tools:ignore="MissingDefaultResource,PrivateResource">false</bool> | |
<dimen name="preference_category_padding_start" tools:ignore="MissingDefaultResource,PrivateResource">0dp</dimen> | |
</resources> | |
The <bool> fixes the default value of iconSpacePreserved for all Preference; The <dimen> fixes the PreferenceCategory. | |
EDIT: If you are using androidx.preference:preference:1.1.1, you won't need the dimen preference_category_padding_start. Tested on Android 6-10. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment