`
貌似掉线
  • 浏览: 256583 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

设置tabWidget标题的字体大小及颜色

阅读更多
/*  
 * @(#)TextAppearenceUtil.java              Project:RTKSETTINGS  
 * Date:2013-1-9  
 *  
 * Copyright (c) 2013 Geek_Soledad.  
 * All rights reserved.  
 *  
 * Licensed under the Apache License, Version 2.0 (the "License");  
 *  you may not use this file except in compliance with the License.  
 * You may obtain a copy of the License at  
 *  
 *     http://www.apache.org/licenses/LICENSE-2.0  
 *  
 * Unless required by applicable law or agreed to in writing, software  
 * distributed under the License is distributed on an "AS IS" BASIS,  
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
 * See the License for the specific language governing permissions and  
 * limitations under the License.  
 */
package com.realtek.msdx.rtksettings.util;

import android.content.Context;
import android.widget.TabWidget;
import android.widget.TextView;

/**
 * @author Geek_Soledad (msdx.android@tom.com)
 */
public class TextAppearanceUtil {

	/**
	 * 设置TabWidget的标题的字体
	 * 
	 * @param tabWidget
	 *            要设置的TabWidget
	 * @param size
	 *            字体大小
	 */
	public static void setTabWidgetTitle(TabWidget tabWidget, int size) {
		for (int i = 0, count = tabWidget.getChildCount(); i < count; i++) {
			((TextView) tabWidget.getChildAt(i)
					.findViewById(android.R.id.title)).setTextSize(size);
		}
	}

	/**
	 * 设置TabWidget
	 * 
	 * @param tabWidget
	 *            要设置的TabWidget
	 * @param size
	 *            字体大小
	 * @param color
	 *            字体颜色
	 */
	public static void setTabWidgetTitle(Context context, TabWidget tabWidget, int size,
			int color) {
		TextView tv = null;
		for (int i = 0, count = tabWidget.getChildCount(); i < count; i++) {
			tv = ((TextView) tabWidget.getChildAt(i).findViewById(
					android.R.id.title));
			tv.setTextSize(size);
			tv.setTextColor(context.getResources().getColorStateList(color));
		}
	}
}


使用方法:
		TextAppearanceUtil.setTabWidgetTitle(tabHost.getTabWidget(), 25);
0
6
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics