2

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)

andineupert
  • 341
  • 2
  • 6
  • 19

2 Answers2

3

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.

Mel
  • 6,214
  • 10
  • 54
  • 71
  • I had to use a custom layout defined in xml like it is described here: [link](http://stackoverflow.com/questions/6194116/creating-a-custom-layout-for-preferences) and then set the title textview to TextAppearance.Medium like you said and adjust the margin-left. Now it looks good. Thanks! – andineupert Jul 02 '12 at 11:54
0

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>
Amir
  • 8,821
  • 7
  • 44
  • 48
MobileMon
  • 8,341
  • 5
  • 56
  • 75