修改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命令行字体大小
打开命令行窗口: 在标题栏处右键单击-->属性,然后更改即可
随机推荐
- java--内部类实现“类的多重继承”
class Fa1{ private int k = 1; void show() { System.out.println(k); } } class Fa2{ private int k = 10 ...
- 高级UIKit-01(总结基础UIKit)
总结: 如果相同的控件大于等于3个就拖成一个属性选用outlet Collection 提升局部变量的方法:传参或改变全局 创建CGImage对象要释放,因为ARC只会自动释放OC方法,这个是CG框架 ...
- C# 使用IENUMERABLE,YIELD
C# 使用IENUMERABLE,YIELD 前言 在上篇文章中我得出结论,遍历迭代器修改迭代器中项目的值未生效,是因为使用了yield return,并且每次遍历迭代器都执行返回迭代器的方法.这篇文 ...
- Tri_integral Summer Training 9 总结
比赛链接 A B C D H I J K 多灾多难的 Summer Training 9,前一天挂了一场比赛,结果题一半不能做,于是打了一个小时就放弃了.之后的两场Summer Training 9一 ...
- perl 传递对象到模块
perl 中的对象 就是引用 通过new方法传递数据结构给各个模块 [root@wx03 test]# cat x1.pm package x1; use Data::Dumper; sub new ...
- [置顶] 编程模仿boost::function和boost::bind
boost::function和boost::bind结合使用是非常强大的,他可以将成员函数和非成员函数绑定对一个对象上,实现了类似C#的委托机制.委托在许多时候可以替代C++里面的继承,实现对象解耦 ...
- eclipse的SVN插件的配置
http://www.cnblogs.com/kekec/archive/2010/08/09/1795581.html
- 柔性数组-读《深度探索C++对象模型》有感
最近在看<深度探索C++对象模型>,对于Struct的用法中,发现有一些地方值得我们借鉴的地方,特此和大家分享一下,此间内容包含了网上搜集的一些资料,同时感谢提供这些信息的作者. 原文如下 ...
- .net版Git Server --- bonobo
官网地址: https://bonobogitserver.com/ Demo: http://demo.bonobogitserver.com/Home/LogOn 登入admin:admin C ...
- 终于懂了:Delphi重定义消息结构随心所欲,只需要前4个字节是消息编号就行了(有了这个,就有了主动)
Delphi重定义消息结构随心所欲,只需要前4个字节是消息编号就行了,跟Windows消息虽然尽量保持一致,但其实相互没有特别大的关系.有了这个,就有了主动,带不带句柄完全看需要. 比如这个结构就带句 ...