修改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命令行字体大小
打开命令行窗口: 在标题栏处右键单击-->属性,然后更改即可
随机推荐
- 基于visual Studio2013解决算法导论之004随机排列数组
题目 随机排列数组 解决代码及点评 #include <stdio.h> #include <stdlib.h> #include <malloc.h> # ...
- Haxe UI框架StablexUI的使用备忘与心得(一)
这一节先来说说StablexUI的基本方面. 安装与使用,在官方文档里Getting Started一章里写的很清楚,这里就不展开了,简单总结来说: * StablexUI依赖于actuate缓动库和 ...
- PHP - 递归函数
/** * factorial($num) 计算阶乘 * @param string $num * @return string $total */ function factorial($num) ...
- BZOJ 1592: [Usaco2008 Feb]Making the Grade 路面修整( dp )
最优的做法最后路面的高度一定是原来某一路面的高度. dp(x, t) = min{ dp(x - 1, k) } + | H[x] - h(t) | ( 1 <= k <= t ) 表示前 ...
- ean128与code128 条形码 算法分析
[code128条形码组成] 除终止符(STOP)由13个模块组成外,其他字符均由11个模块组成 就是说,如果用‘1’表示黑线(实模块),用‘0’表示白线(空模块),那么每表示一个字符就需要11条线, ...
- 监听手机晃动(摇一摇)SensorEventListener
import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorEvent; ...
- linux命令:du,看文件大小
du -s698 . (698字节)From <http://jingyan.baidu.com/article/a17d52855c10bf8098c8f2c9.html>
- Qt5.2 android 环境搭建及其测试
1.<安装> 软件: qt-windows-opensource-5.2.0-android-x86-win32-offline //Qt开发环境 adt-bundle-windows-x ...
- Codility上的问题 (17) PI 2012
这个题比较简单,给定一个整数数组,对每个元素,求出和它最近比它大的数的距离(下标绝对值),如果没有比它大的数,认为距离是0. 数组元素个数 N [0..50000],数组元素范围[-10^9, +10 ...
- CppCMS URL使用
Artyom觉得URL分为三个组成部分: Script_Name / Path_Info ? Query_String 比方以下的: /foo/bar.php/test?x=10 Script_Nam ...