1

The question:

How do you change the text size used for the android:title attribute when the Preference items are listed in the settings menu?

The details:

The Settings screen in my app looks good on a Nexus 7 (Jelly Bean) tablet, but is almost unusable on a Motorola Defy (Gingerbread) phone. I am using the standard PreferenceActivity approach as detailed in the Android Dev guides.

I have been searching the web for several days, but have not found a solution that makes things look any different.

On the Android-Gingerbread phone;

1) the <EditTextPreference android:title .../> text is way too big, and doesn't word-wrap.

2) the standard "down arrow" icons next to each preference item look weird and misaligned. (misaligned icon image)

3) the theme is Holo, but a large blank region below the last preference item is an ugly light grey for some reason.

I've tried defining style.xml resources and putting style="@style/StyleName" in the preferences.xml to change the android:textSize attribute, but it didn't do anything.

Below is the XML for my preference screen:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/SettingsMenu" >

    <PreferenceCategory 
        android:key="pref_key_mixProportions" 
        android:title="@string/pref_title_mixProportions"
        style="@style/SettingsMenu"
        >
        <EditTextPreference 
            android:key="pref_key_binderPortion"
            android:title="@string/pref_title_binderPortion"
            android:dialogTitle="Binder Portion"
            android:inputType="numberDecimal"
            android:maxLines="2"
            android:scrollHorizontally="false"
            android:defaultValue="1"
            android:persistent="true" />

        <EditTextPreference 
            android:key="pref_key_premixPortion"
            android:title="@string/pref_title_premixPortion"
            android:dialogTitle="Premix Portion"
            android:inputType="numberDecimal"
            android:layout_width="wrap_content"
            android:maxLines="2"
            android:scrollHorizontally="false"
            android:defaultValue="5"
            android:persistent="true"/>
    </PreferenceCategory>

    <PreferenceCategory 
        android:key="pref_key_binderProperties" 
        android:title="@string/pref_title_binderProperties">
        <EditTextPreference 
            android:key="pref_key_binderDensity"
            android:title="@string/pref_title_binderDensity"
            android:dialogTitle="Density of Binder powder (kg/m^3)"
            android:inputType="numberDecimal"
            android:defaultValue="2850"
            android:persistent="true"
            android:summary="@string/pref_summary_binderDensity"/>
        <EditTextPreference 
            android:key="pref_key_binderBagWeight"
            android:title="@string/pref_title_binderBagWeight"
            android:dialogTitle="Weight of Binder per bag (kg)"
            android:inputType="numberDecimal"
            android:defaultValue="20"
            android:persistent="true" />

    </PreferenceCategory>

    <PreferenceCategory 
        android:key="pref_key_premixProperties" 
        android:title="@string/pref_title_premixProperties">
        <EditTextPreference 
            android:key="pref_key_premixDensity"
            android:title="@string/pref_title_premixDensity"
            android:dialogTitle="Density of Sand and Aggregate Mix (kg/m^3)"
            android:inputType="numberDecimal"
            android:defaultValue="1850"
            android:persistent="true"
            android:summary="@string/pref_summary_premixDensity"/>

    </PreferenceCategory>

</PreferenceScreen>

My styles.xml contains:

<style name="SettingsMenu">
    <item name="android:textSize">15sp</item>
</style>

But the text looks the same regardless of what value I give for the size.

I've seen that some people suggest using <PreferenceScreen android:layout=".... /> but I've found no clear explanation of how this is done.

Can anyone help?

Sound Conception
  • 5,263
  • 5
  • 30
  • 47
  • 1
    edit your post with the image link in it and Ill inline it or just post url here. If you need to upload somewhere first, upload to imgur – ObieMD5 Jul 20 '13 at 15:07
  • "the theme is Holo dark" -- there is no `Theme.Holo` or `Theme.Holo.Dark` on Android 2.3. – CommonsWare Jul 20 '13 at 15:21
  • Try using the ActionBarSherlock. That emulates the styles from newer Android versions. – rekire Jul 20 '13 at 21:41
  • HoloEverywhere is what you want if you're trying to replicate the Holo style on all platforms. – hwrdprkns Jul 21 '13 at 02:08
  • I've uploaded the image to imgur and edited the post. – Sound Conception Jul 21 '13 at 06:39
  • I've re-written the app to use ActionBarSherlock. This has fixed the icon display problem. Thank you rekire. From my reading, I think HoloEverywhere would have also worked, as suggested by hwrdprkns. Unfortunately this has not solved my Preference heading font size problem, so I'm going to try making a custom preference screen. – Sound Conception Jul 30 '13 at 11:53

1 Answers1

0

Add the style file to the manifest declaration next to the prefernces activity - something like

<activity
    android:name="com.example.PrefsActivity"
    android:theme="@style/PreferencesStyle" >
</activity>

that will do the trick

crazyPixel
  • 2,301
  • 5
  • 24
  • 48