2012-06-25 49 views
1

我正在使用PreferenceScreen以及一些不同的首选项。我还使用扩展DialogPreference的自定义首选项。现在,自定义DialogPreference的字体大小与其他首选项的字体大小不同。我试图将一种风格应用于偏好活动,但我只是达到了所有字体都具有相同的大小(标题和摘要)。Android DialogPreference布局TextSize

有没有另一种方法让所有的偏好看起来都一样? 谢谢!

(我看了一下查看其它问题DialogPreferences,但我无法找到一个解决方案,所以我希望这不是太冗余)

回答

3

尝试在您的自定义偏好使用预定义的Android风格。例如,使用

@android:style/TextAppearance.Medium

正常TextViews和

@android:style/TextAppearance.Large

Four的标题TextViews。

+0

好吧,我会试试这个..谢谢! – andineupert

+0

我不得不使用在xml中定义的自定义布局,如下所示:[link](http://stackoverflow.com/questions/6194116/creating-a-custom-layout-for-preferences),然后设置标题Textview到TextAppearance.Medium就像你说的那样调整左边距。现在看起来不错。谢谢! – andineupert

0

应该不会有这个困难,但它是:

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

布局:

<?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>