赞
踩
修改字体大小、样式、颜色
package com.android.fadi.powersave.view; import android.content.Context; import android.graphics.Color; import android.graphics.Typeface; import android.preference.PreferenceCategory; import android.util.AttributeSet; import android.view.Gravity; import android.view.View; import android.widget.LinearLayout; import android.widget.TextView; import com.android.fadi.powersave.util.ScreenUtils; public class DamiPreferenceCategory extends PreferenceCategory { public DamiPreferenceCategory(Context context) { super(context); } public DamiPreferenceCategory(Context context, AttributeSet attrs) { super(context, attrs); } public DamiPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onBindView(View view) { super.onBindView(view); view.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, ScreenUtils.dpToPxInt(getContext(), 32))); if (view instanceof TextView) { TextView tv = (TextView) view; tv.setBackgroundColor(Color.parseColor("#fafafa")); tv.setTextColor(Color.parseColor("#009688"));// 字体颜色 tv.setSingleLine(true); tv.setPadding(tv.getPaddingLeft(), 0, tv.getPaddingLeft(), 0); tv.setGravity(Gravity.CENTER_VERTICAL); tv.setTypeface(Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL));// 字体风格 tv.setTextAlignment(View.TEXT_ALIGNMENT_VIEW_START); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。