手机
当前位置:查字典教程网 >编程开发 >安卓软件开发 >Android设置PreferenceCategory背景颜色的方法
Android设置PreferenceCategory背景颜色的方法
摘要:本文实例讲述了Android设置PreferenceCategory背景颜色的方法。分享给大家供大家参考。具体分析如下:大家可能遇到,Pre...

本文实例讲述了Android设置PreferenceCategory背景颜色的方法。分享给大家供大家参考。具体分析如下:

大家可能遇到,PreferenceCategory默认是黑色背景,如何我们更换了PreferenceScreen的背景,那么这种分隔栏看上去很丑,那么怎么更改背景呢?我们可以通过自定义VIEW来实现。

代码如下:

public class MyPreferenceCategory extends PreferenceCategory { public MyPreferenceCategory(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onBindView(View view) { super.onBindView(view); view.setBackgroundColor(Color.parseColor("#b0000000")); if (view instanceof TextView) { TextView tv = (TextView) view; tv.setTextSize(16); tv.setTextColor(Color.BLACK); } } }

在xml调用时(自定义用法。。。你懂的):

<com.blogchen.myview.MyPreferenceCategory android:title="其他" > <PreferenceScreen android:key="blog_" android:summary="作者博客地址" android:title="访问博客" > <intent android:action="android.intent.action.VIEW" android:data="http://www.jb51.net" /> </PreferenceScreen> </com.blogchen.myview.MyPreferenceCategory>

希望本文所述对大家的Android程序设计有所帮助。

【Android设置PreferenceCategory背景颜色的方法】相关文章:

Android上网获取网络上的图片方法

Android上使用jspf插件框架的方法

Android HttpURLConnection.getResponseCode()错误解决方法

使用android隐藏api实现亮度调节的方法

Android开发笔记 改变字体颜色的三种方法

android TextView设置中文字体加粗实现方法

Android 用SQLite实现事务的方法

Android Intent启动别的应用实现方法

android中path的arcTo方法

Android之PreferenceActivity应用详解(2)

精品推荐
分类导航