android:如何向tabhost和标签添加样式或背景

时间:2013-01-26 14:54:22

标签: android android-layout android-tabs android-style-tabhost

就像android联系人中的标签一样,我想添加样式(或者可能是背景或者我不知道的东西)怎么样?

<?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">
    <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" />
        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"/>
    </LinearLayout>
</TabHost>

并且你能告诉我在哪里可以找到好的背景或标签,因为我不擅长设计:)

1 个答案:

答案 0 :(得分:5)

在这里你可以获得关于标签的所有信息。适用于Android 1.6及更高版本:http://joshclemm.com/blog/?p=136

你必须在你的TabSpec上调用setIndicator并传递一个视图而不仅仅是文本。然后,您可以使用选择器等自定义该视图。