Search code examples
androidresourcesduplicatesandroid-preferencesarrays

Android string array resource: duplicate xml declaration for larger screens?


I have this string array resource in /res/values/arrays.xml, for a ListPreference:

<string-array name="pref_font_size_entries">
    <item>Small</item>
    <item>Normal</item>
    <item>Large</item>
    <item>Extra Large</item>
</string-array>

If I want to add an extra list item (see the last <item>Huge</item>) on larger screens, do I have to duplicate the entire declaration in /res/values-sw600dp/arrays.xml?

<string-array name="pref_font_size_entries">
    <item>Small</item>
    <item>Normal</item>
    <item>Large</item>
    <item>Extra Large</item>
    <item>Huge</item>
</string-array>

Solution

  • Yes, you have to duplicate the entire definition of pref_font_size_entries as they are not cumulative. Android picks the XML file which fits the resolution the best. If you have other definitions here or other XML files in /res/values which are the same for /res/values-sw600dp you don't need to duplicate those.