修改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命令行字体大小
打开命令行窗口: 在标题栏处右键单击-->属性,然后更改即可
随机推荐
- 高级UIKit-04(NSUserDefaults、NSKeyedArchiver、对象归档方法)
[day05_1_UserDefault]:判断应用程序是否是第一次运行 NSUserDefaults:用来保存应用程序的配置信息如:程序运行次数,用户登陆信息等. // 使用系统提供的NSUserD ...
- Rfc2898DeriveBytes解密如何通过java实现
原文 Rfc2898DeriveBytes解密如何通过java实现 这个找了半天,还是不太懂,密码一点不懂,直接上来问了 Rfc2898DeriveBytes对应的是PBKDF2WithHmacSHA ...
- 分享非常有用的Java程序 (关键代码) (一)
原文:分享非常有用的Java程序 (关键代码) (一) 分享一些非常有用的Java程序 (关键代码) ,希望对你有所帮助. 1. 得到当前方法的名字 String methodName = Th ...
- android-studio 安装gradle
http://services.gradle.org/distributions 下载需要的gradle 放到C:\Users\Administrator\.gradle\wrapper\dists\ ...
- Ubuntu一些配置和技巧
安装google-chrome wget https://dl.google.com/linux/direct/google-chrome-stable_current_i386.deb sudo d ...
- Vbox视图热键
Vbox屏幕热键 在Vbox中一般host主键会默觉得"右Ctrl",例如以下图所看到的,在选择自己主动调整窗体后,"视图"选项栏会消失.这时若想更改视图设置能 ...
- NET 2016
.NET 2016 阅读目录 初识 .NET 2016 使用 .NET Framework 4.6 编译应用程序 使用 .NET Core CLI 编译应用程序 小结 厚积薄发这个词是高三英语老师 ...
- 基于visual Studio2013解决C语言竞赛题之1040因数分解
题目 解决代码及点评 /* 将一个数M分解为质因数(M≠0). */ #include <stdio.h> #include <stdlib.h> void main() ...
- CentOS 配置 ssh
默认安装ssh是有的.只是hosts访问问题. 1.在hosts.deny文件尾添加sshd:ALL意思是拒绝所有访问请求 [root@localhost ~]# vi /etc/hosts.de ...
- java运行脚本语言demo
public class Test { /** * @param args * @throws IOException */ public static void main(String[] arg ...