2

I have set up a ListPreference with a key, title and entries, etc. It looks like this in XML:

<ListPreference
        android:key = "@string/pref_currency"
        android:title="@string/settings_currency_title"
        android:dialogTitle="@string/settings_currency_title"
        android:entries="@array/locale_entries"
        android:entryValues="@array/locale_entry_values"/>

It sits with a PreferenceScreen.

When I open the ListPreference by clicking on it in my application it looks like this:

ListPreference Screenshot

The theme I am using for my app is as follows:

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:textColorPrimary">@color/primary_text</item>
    <item name="android:textColorSecondary">@color/secondary_text</item>
    <item name="windowNoTitle">true</item>
    <item name="windowActionBar">true</item>
    <item name="android:fitsSystemWindows">true</item>
</style>

I was expecting there to be some margin or padding around the title and the cancel button. Does anybody know why there isn't any? Is it meant to look this ugly by default?

Also, does anybody know how I could add some padding to both the title and cancel button?

James Warner
  • 385
  • 2
  • 14

1 Answers1

0

The problem is in your styles.xml file. If you row <item name="android:fitsSystemWindows">true</item> from your theme or set its value to false everything will work as expected.

android:fitsSystemWindows

Boolean internal attribute to adjust view layout based on system windows such as the status bar. If true, adjusts the padding of this view to leave space for the system windows. Will only take effect if this view is in a non-embedded activity.

Community
  • 1
  • 1
Volodymyr
  • 6,393
  • 4
  • 53
  • 84