六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 57|回复: 0

(android实战)自定义android的tab样式--转载

[复制链接]

升级  18.4%

192

主题

192

主题

192

主题

进士

Rank: 4

积分
592
 楼主| 发表于 2013-1-3 16:59:01 | 显示全部楼层 |阅读模式
(android实战)自定义android的tab样式--转载

<div id="cnblogs_post_body">android项目中碰到需要替换tabHost默认样式的情况,需要达到下图的效果:
(实现原理,重构Tab的Indicator)


为了做成这样的效果,花了些时间,这里做个笔记,给有需要的朋友。

步骤一:新建一个xml布局文件,命名main.xml
<div style="color: #000000; background-color: #eeeeee; font-family: Verdana,宋体; width: 98%; line-height: 16px; border: #cccccc 1px solid; padding: 4px; font-size: 10pt; word-break: break-all;"><?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@android:id/tabhost" android:layout_width="fill_parent"
  android:layout_height="fill_parent" android:background="@color/white">
  <LinearLayout android:orientation="vertical"
    android:layout_width="fill_parent" android:layout_height="fill_parent">
    <TabWidget android:id="@android:id/tabs"
      android:layout_width="fill_parent" android:layout_height="wrap_content"
      android:gravity="center_horizontal|center_vertical"/>
    <FrameLayout android:id="@android:id/tabcontent"
      android:layout_width="fill_parent" android:layout_height="fill_parent">
    </FrameLayout>
  </LinearLayout>
</TabHost>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表