|
|
(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> |
|