<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="First Category"
android:textSize="20px">
<CheckBoxPreference
android:title="Checkbox Preference"
android:defaultValue="false"
android:summary="This preference can be true or false"
android:key="checkboxPref" />
</PreferenceCategory>
</PreferenceScreen>
我需要改变android:title
字体大小的PrefereceCategory
,CheckboxPreference
和android:summary
的大小。这些标记没有任何android:textSize
属性。有谁能帮我弄到这个吗?
发布于 2013-04-17 02:08:00
对我来说,praneetloke发布的布局让小部件从有关联小部件的首选项中消失了,例如复选框。小部件需要一个id为/ widget _ LinearLayout的框架。下面的方法适用于我,在Android2.3到4.2.2之间。我需要做的唯一更改是在包含首选项图标的布局上设置android:visibility=“消失”,这在姜饼中是不可用的。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingLeft="8dip"
android:paddingRight="?android:attr/scrollbarSize" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:minWidth="0dp"
android:orientation="horizontal"
android:visibility="gone" >
<ImageView
android:id="@+android:id/icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:minWidth="48dp"
android:paddingRight="8dip" />
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingBottom="6dip"
android:paddingRight="8dip"
android:paddingTop="6dip" >
<TextView
android:id="@+android:id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@android:id/title"
android:layout_below="@android:id/title"
android:maxLines="4"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="?android:attr/textColorSecondary" />
</RelativeLayout>
<!-- Preference should place its actual preference widget here. -->
<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" />
</LinearLayout>
引用:布局中使用的默认尺寸在这里是GrepCode /res/values/dimens.xml。实际的首选项布局在这里是GrepCode /res/layout/preference_holo.xml。请注意,还有一个称为preference.xml的非全息版本。
发布于 2012-12-05 09:38:54
我在ICS及更高版本中修改了Kumar的答案。我将此布局放在values-v11中,以实现目标设备的API级11+。
<?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="18dp"
android:textColor="?android:attr/textColorPrimary"
android:paddingLeft="8dip"/>
<TextView android:id="@+android:id/summary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="?android:attr/textColorSecondary"
android:paddingLeft="8dip"/>
</LinearLayout>
发布于 2013-11-30 02:35:03
看看我对这个问题的回答:Android PreferenceScreen title in two lines。
如果需要,您还可以更改字体本身。只需添加以下内容:
Typeface myTypeface = Typeface.createFromAsset(textView.getContext().getAssets(),"fonts/your_font_name.ttf");
if (textView != null) {
textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textView.getContext().getResources().getDimension(R.dimen.text_size_from_dimen));
textView.setTypeface(myTypeface);
}
https://stackoverflow.com/questions/5334828
复制相似问题