【发布时间】:2013-06-02 15:54:31
【问题描述】:
您好,我想更改 android
到
我还想修改它的背景和图标。
我正在使用actiobarsherlock 库。
这是我尝试过的
<?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="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="?attr/actionBarSize"
android:layout_weight="0"
style="@style/ActionBarTabStyle.Example"
android:orientation="horizontal"
android:tabStripEnabled="false" />
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<com.mainapp.CustomViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
</TabHost>
风格
<style name="ActionBarTabStyle.Example" parent="@style/Widget.Sherlock.Light.ActionBar.TabView">
<item name="android:background">@drawable/tab_indicator_ab_example</item>
</style>
-
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab_selected_focused_example" />
<!-- Pressed -->
<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="false" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" />
<!-- Focused states -->
<item android:state_focused="true" android:state_selected="false" android:state_pressed="true" android:drawable="@drawable/tab_unselected_pressed_example" />
<item android:state_focused="true" android:state_selected="true" android:state_pressed="true" android:drawable="@drawable/tab_selected_pressed_example" />
</selector>
谢谢!
【问题讨论】:
-
你用的什么风格?
-
您好,我更新了问题。
-
而选择器中使用的drawable是?
-
jgilfelt.github.io/android-actionbarstylegenerator 我使用这个网站来生成这些drawable。但是,如果我从 TabHost 中删除
style="@style/ActionBarTabStyle.Example"行,那么似乎什么都没有改变。 -
如果删除样式不会改变事情,那么其他东西会弄乱标签。我觉得奇怪的一件事是你为什么使用
android:layout_marginTop="?attr/actionBarSize"属性?
标签: android actionbarsherlock android-tabs