Android设置PreferenceCategory背景颜色的方法
16lz
2021-01-26
本文实例讲述了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调用时(自定义用法。。。你懂的):
希望本文所述对大家的Android程序设计有所帮助。
更多相关文章
- Android(安卓)Studio中读取文本文件内容方法
- Android(安卓)Studio 自定义皮肤主题和背景
- 图片阴影
- Android(安卓)中TabLayout自定义选择背景滑块的实例代码
- Android(安卓)带输入框圆角Dialog--EditDialog
- Auto.js逆向分析-提取脚本文件(附源码)
- android-魔法泡泡动画分析(附源码)
- android4.4 launcher2实现应用列表背景透明
- Android自定义ActionBar背景色、字体颜色等样式style