As you can see in the image, it is taking some additional space in left . Later I have found that this space is assigned for icon. How can I remove this space?
I have tried preference.setIcon(null);
Also I have tried the solution given here . But no luck .
I am using compile 'com.android.support:preference-v7:25.1.1'
Edit
Here is my style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="preferenceTheme">@style/PreferenceThemeOverlayCustom</item>
</style>
<style name="PreferenceThemeOverlayCustom" parent="PreferenceThemeOverlay">
<item name="preferenceFragmentListStyle">@style/PreferenceFragmentListCustom</item>
</style>
<style name="PreferenceFragmentListCustom" parent="PreferenceFragmentList">
<item name="android:paddingEnd">0dp</item>
<item name="android:paddingLeft">0dp</item>
<item name="android:paddingRight">0dp</item>
<item name="paddingStart">0dp</item>
</style>
Constructing the new preference like this:
new Preference(getPreferenceScreen().getContext());
should solve the issue.
As mentioned by guillaume-tgl the explanation can be found here.
Edit: Using the new support library (28.0.0) you should also call:
preference.setIconSpaceReserved(false);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With