Question

I'm using a PreferenceScreen with some different preferences. I'm also using a custom preference extending DialogPreference. Now the fontsize of the custom DialogPreference is different than the font size of the other preferences. I tried to apply a style to the preference activity but I just reached that all fonts got the same size (title and summary).

Is there another way to let all preferences look the same way? Thanks!

(I took a look at a view other questions to DialogPreferences but I could not find a solution for this, so I hope this isn't too redundant)

Was it helpful?

Solution

Try using the predefined Android styles in your custom preference. For example, use

@android:style/TextAppearance.Medium

for normal TextViews, and

@android:style/TextAppearance.Large

four your heading TextViews.

OTHER TIPS

It should not have been this hard but it is:

 <com.yourpackage.CustomPreference
        android:dialogMessage="@string/summary"
        android:summary="@string/summary"
        android:title="@string/title"
        android:key="preference"
        android:layout="@layout/custom_preference_title"
        />

Layout:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:minHeight="?android:attr/listPreferredItemHeight">

<TextView
    android:id="@+android:id/title"
    style="@android:style/TextAppearance.Medium"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_marginLeft="?android:attr/listPreferredItemPaddingLeft"
    android:text="test" />

</RelativeLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top