修改Tabhost样式和字体大小和居中显示
有时候我们的tabhost并不需要贴图,所以这个时候就必须把文字居中显示和设置大小了,代码如下
setContentView(R.layout.home_vzo_tabhost);
tabHost = getTabHost();
tabWidget = tabHost.getTabWidget();
TabHost.TabSpec spec;
Intent intent;
//indicator指示器
intent = new Intent(this,HomeVzoBasicInfoActivity.class); //把值传给启动的界面
//名字;要显示的字符;设置动画
spec = tabHost.newTabSpec("a1").setIndicator(getResources().getString(R.string.baseInfo))
.setContent(intent);//设置一个Acitivity
tabHost.addTab(spec);
intent = new Intent(this,HomeVzoContentActivity.class);
spec = tabHost.newTabSpec("a2").setIndicator(getResources().getString(R.string.myPull))
.setContent(intent);
tabHost.setOnTabChangedListener(this);
tabHost.addTab(spec);
for (int i =0; i < tabWidget.getChildCount(); i++) {
//修改Tabhost高度和宽度
// tabWidget.getChildAt(i).getLayoutParams().height = 30;
// tabWidget.getChildAt(i).getLayoutParams().width = 65;
//修改显示字体大小
TextView tv = (TextView) tabWidget.getChildAt(i).findViewById(android.R.id.title);
tv.setTextSize(18);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) tv.getLayoutParams();
params.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 0); //取消文字底边对齐
params.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE); //设置文字居中对齐
}
tabHost.setCurrentTab(0);
配置文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
style="@style/vzo_ll">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher"
android:layout_marginTop="20dip"
android:layout_marginBottom="15dip"
android:layout_marginLeft="15dip"/>
<FrameLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:background="@drawable/item_bg_whilt"
android:layout_marginTop="20dip"
android:layout_marginBottom="15dip"
android:layout_marginRight="10dip"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/neckName"
android:gravity="center"
android:layout_marginLeft="5dip"
android:layout_marginRight="5dip"
android:drawableRight="@drawable/tab_sms_selected"
android:layout_gravity="left|center_vertical"/>
<TextView
android:id="@+id/neckName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/neckName"
android:gravity="center"
android:textColor="#558800"
android:layout_marginLeft="5dip"
android:layout_gravity="center"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</FrameLayout>
</LinearLayout>
<TabHost
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:tabStripEnabled="false"
android:animateLayoutChanges="true">
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" >
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
修改Tabhost样式和字体大小和居中显示的更多相关文章
- 修改XtraMessageBox的内容字体大小
修改XtraMessageBox的内容字体大小 public static DialogResult Show(UserLookAndFeel lookAndFeel, IWin32Window ow ...
- ggplot2画histogram(坐标轴刻度值字体大小,坐标轴标题字体大小,柱形宽度,大标题字体大小、居中)
见链接:https://www.r-bloggers.com/how-to-make-a-histogram-with-ggplot2/ 写的很完整. 此外,关于一些参数的用法: theme(plot ...
- IDEA 官方背景与修改jsp模板以及字体大小
一.官方背景切换 方法一:先打开file找到Settings 如图: 也可以用快捷方式打开:Ctrl+alt+s 打开 找到Editor点击进入 ,再然后找Color Scheme 可以看到如下图 ...
- AndroidStudio修改主题外观和字体大小
修改主题外观 File --> Settings --> Appearance & Behavior --> Appearance 右边 Theme 修改编辑器的字体大小 F ...
- swift修改UITextfield的Placeholder字体大小和颜色
第一种方法: self.userNumber.setValue(UIColor.lightGray, forKey: "_placeholderLabel.textColor") ...
- IDEA中修改各个部位的字体大小
1.菜单栏 Setting -> Appearance&Behavior -> Appearance ->Override default fonts by (not rec ...
- 修改WordPress标签云字体大小颜色及标签显示数量
WordPress 自带的标签云是一个很实用的小工具.站长可以通过标签对具有相同关健词的文章进行检索分类,利于访客查找相关文章.WordPress 默认标签云的字体最小为8pt,最大为22pt,标签显 ...
- VS2008中设置字体大小和添加显示行号
1.字体设置 菜单->工具->选项->环境->字体和颜色 在字体那一栏可以选字体,VC6.0默认的字体是Fixedsys,字体大小你可以设为12,就与VC6.0的一样的字体了. ...
- 怎么修改windows命令行字体大小
打开命令行窗口: 在标题栏处右键单击-->属性,然后更改即可
随机推荐
- Windows Azure 社区新闻综述(#78 版)
欢迎查看最新版本的每周综述,其中包含有关云计算和 Windows Azure 的社区推动新闻.内容和对话.以下是本周的亮点. 博客文章: 博客:Windows Azure BizTalk 服务:如何开 ...
- 数据绑定以及Container.DataItem几种方式与使用方法分析
灵活的运用数据绑定操作 绑定到简单属性:<%#UserName%> 绑定到集合:<asp:ListBox id="ListBox1" ...
- ASIHTTPRequest-插件的使用
链接地址:http://blog.sina.com.cn/s/blog_7b9d64af0101e5uf.html 一.什么是ASIHTTPRequest ASIHTTPRequest 插件是一个 ...
- 不用SWIG,Go使用C++代码的方式
将C++代码用C作一次封装,就可以让Go调用了. 这是一个C++头文件: ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #ifndef CGO_CPPGO_C ...
- jquery实现ajax提交form表单的方法总结
本篇文章主要是对jquery实现ajax提交form表单的方法进行了总结介绍,需要的朋友可以过来参考下,希望对大家有所帮助 方法一: function AddHandlingFeeToRefund( ...
- java.lang.ClassNotFoundException与java.lang.NoClassDefFoundError的区别(转)
ClassNotFoundException ClassNotFoundException这个错误,比较常见也好理解. 原因:就是找不到指定的class. 常见的场景就是: 1 调用class的for ...
- static在C和C++中的用法和区别
static主要有三个作用: (1)局部静态变量 (2)外部静态变量/函数 (3)静态数据成员/成员函数 前两种C和C++都有,第三种仅在C++中有,下面分别作以下介绍: 一.局部静态变量 在C/C+ ...
- dedecms的安装以及为他配置虚拟主机
一.概念: 1.CMS是:Content Manage System 内容管理系统 内容包括:商品,文章,软件,视频 2.当前市面上常用的CMS有哪些? DedeCMS: 织梦 中小型公司 ...
- java.lang.ClassNotFoundException: org.apache.catalina.loader.DevLoader
eclipse tomcat报错:org.apache.catalina.loader.DevLoader java.lang.ClassNotFoundException: org.apache.c ...
- tcp接收xml数据解析
避免tcp接收xml数据时加上xml数据长度,根据xml数据特点来解析recv到的xml数据 int nPos1 = 0; int nPos2 = 0; int nTempPos = 0; int n ...