I have a preference screen in my app and it is shifted off center and the header text or data doesn't start from the left shown in the image below. I am initializing the settings fragment. I have not applied any visual changes or added any special attributes.
There is no padding or margin in the parent activity. I also have a recycler view which is displayed perfectly fine in the app with it being off centered
This is my preferences.xml file
<androidx.preference.PreferenceScreen
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
app:title="General">
<Preference
app:key="feedback"
app:title="Send Feedback"
app:summary="Report technical issues or suggest new features"/>
<Preference
app:key="about"
app:title="About Us"/>
</PreferenceCategory>
<PreferenceCategory
app:title="Customize">
<SwitchPreferenceCompat
app:key="@string/key_darkTheme"
app:title="Enable Dark Theme"
app:summary="Enable dark theme throughout app (Restarts App Automatically)"
app:defaultValue="false"/>
<ListPreference
app:key="@string/key_font"
app:title="Set Font Size"
app:entries="@array/settings_list_preference_font"
app:entryValues="@array/settings_list_preference_values"
app:defaultValue="2"
app:summary="Set font size according to your liking"/>
</PreferenceCategory>
</androidx.preference.PreferenceScreen>
Probably because the preference automatically give you a space for an icon. You can disable that by disabling the space using app:iconSpaceReserved="false"
in each element.
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:title="your_title"
app:iconSpaceReserved="false">
...
</PreferenceCategory>
</PreferenceScreen>
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