jcaruso
jcaruso

Reputation: 2494

Font Size in Preference

How can I change font size in PreferenceScreen

I'm attempting to do the above... It works like a charm, however my SwitchPreference that i'm using no longer have their toggle button. How do i get the button's back?

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

    <PreferenceCategory 
        android:title="@string/pref_user_profile" 
        android:textSize="20px"
        android:layout="@layout/pref_layout">

        <SwitchPreference 
                android:title="@+string/pref_frequency"
                android:summary="@+string/pref_frequency_summary"
                android:key="frequency" 
                android:defaultValue="true"
            android:layout="@layout/pref_layout"/>

        <SwitchPreference 
                android:title="@+string/pref_time"
                android:summary="@+string/pref_time_summary"
                android:key="time"
                android:defaultValue="true"
            android:layout="@layout/pref_layout"/>

        <SwitchPreference  
                android:title="@+string/pref_symptothermal"
                android:summary="@+string/pref_symptothermal_summary"
                android:key="symptothermal"
                android:defaultValue="true"
            android:layout="@layout/pref_layout"/>

        <SwitchPreference 
                android:title="@+string/pref_cervical_mucus"
                android:summary="@+string/pref_cervical_mucus_summary"
                android:key="cervical_mucus"
                android:defaultValue="true"
            android:layout="@layout/pref_layout"/>    

        <SwitchPreference 
                android:title="@+string/pref_mucus_stamps"
                android:summary="@+string/pref_mucus_stamps_summary"
                android:key="mucus_stamps"
                android:defaultValue="true"
            android:layout="@layout/pref_layout"/>

        <SwitchPreference 
                android:title="@+string/pref_fertile_infertile"
                android:summary="@+string/pref_fertile_infertile_summary"
                android:key="fertile_infertil" 
                android:defaultValue="true"
            android:layout="@layout/pref_layout"/>
    </PreferenceCategory>

</PreferenceScreen>

And

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

    <TextView android:id="@+android:id/title"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="15sp"/>  

    <TextView android:id="@+android:id/summary"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textSize="12sp"/>

</LinearLayout>

Upvotes: 1

Views: 5371

Answers (2)

ichalos
ichalos

Reputation: 527

Concluding the answer...
The layout should contain a TextView with id "@+android:id/title", a second one with id "@+android:id/summary" and finally (and most important) a container for the preference component with the id "@+android:id/widget_frame". Here is my proposal.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:baselineAligned="false"
    android:padding="10dp"
    android:weightSum="100" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="50"
        android:orientation="vertical" >

        <TextView
            android:id="@+android:id/title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+android:id/summary"
            style="@style/SmallText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textColor="@android:color/darker_gray" />
    </LinearLayout>

    <LinearLayout
        android:id="@+android:id/widget_frame"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:gravity="center"
        android:minWidth="64dp"
        android:orientation="vertical"
        android:layout_weight="50" />
</LinearLayout>

You should be aware to style the two textboxes accordingly.

Upvotes: 1

jcaruso
jcaruso

Reputation: 2494

I found this little snip that fixed it

<LinearLayout
    android:id="@+android:id/widget_frame"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:gravity="center"
    android:minWidth="48dp"
    android:orientation="vertical" />

Upvotes: 0

Related Questions