当前位置:我的异常网» Android » android 批改preference中view属性(title,summary字
android 批改preference中view属性(title,summary字体颜色等)
www.myexceptions.net 网友分享于:2013-03-26 浏览:286次
android 修改preference中view属性(title,summary字体颜色等)
有些时候,我们并不需要系统给我们的这么单调的ui,我们通常会修改一些属性,比如 view的背景,字体的属性等,那么这个时候有两种选择:
1.针对单个应用程序,定义一个cutom的layout,当然这个 layout跟系统的layout元素要一致(否则你怎么改呢?),然后在preference.xml(文件名你自己随便取)android:layout添加你定一个 的layout就可以了。
2.针对整个android系统,修改preference 相关的属性,那么所有的用到PreferenceActivity的界面都会相应的改变。这里只需要修改相应的系统layout文件(在 framework/base/core/res/res/layout),比如preference_category.xml等。
1.先说说地一种吧,比较常用到的。
首先,定义你的layout文件,这个layoutn你直接到framework拷下来,这里标记为custom_preference.xml
android:layout_width="match_parent" android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:gravity="center_vertical" android:paddingRight="?android:attr/scrollbarSize">
android:layout_height="wrap_content" android:layout_marginLeft="15dip"
android:layout_marginRight="6dip" android:layout_marginTop="6dip"
android:layout_marginBottom="6dip" android:layout_weight="1">
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:singleLine="true" android:textAppearance="?android:attr/textAppearanceLarge"
android:ellipsize="marquee" android:fadingEdge="horizontal"
android:textColor="#475ad7"/>
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_below="@android:id/title" android:layout_alignLeft="@android:id/title"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#5ad747"/>
android:layout_width="wrap_content" android:layout_height="match_parent"
android:gravity="center_vertical" android:orientation="vertical"/>
然后,你在些preference.xml文件的时候,应用到这个layout文件。
android:title="checkbox_title"
文章评论