欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android設(shè)置PreferenceCategory背景顏色的方法

 更新時間:2015年05月21日 10:58:22   作者:3H  
這篇文章主要介紹了Android設(shè)置PreferenceCategory背景顏色的方法,涉及Android設(shè)置背景色的技巧,需要的朋友可以參考下

本文實例講述了Android設(shè)置PreferenceCategory背景顏色的方法。分享給大家供大家參考。具體分析如下:

大家可能遇到,PreferenceCategory默認是黑色背景,如何我們更換了PreferenceScreen的背景,那么這種分隔欄看上去很丑,那么怎么更改背景呢?我們可以通過自定義VIEW來實現(xiàn)。

代碼如下:

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調(diào)用時(自定義用法。。。你懂的):

<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.dbjr.com.cn" />
  </PreferenceScreen>
</com.blogchen.myview.MyPreferenceCategory>

希望本文所述對大家的Android程序設(shè)計有所幫助。

相關(guān)文章

最新評論