【发布时间】:2015-04-23 08:10:08
【问题描述】:
我已经设置了我的 tabhost 背景颜色,但它不起作用。
styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
<item name="actionBarTabStyle">@style/ActionBarTabStyle</item>
</style>
<style name="ActionBarTabStyle"
parent="@style/Widget.AppCompat.ActionBar.TabView">
<item name="android:background">@drawable/tab_bg_selector</item>
<item name="background">@drawable/tab_bg_selector</item>
</style>
tab_bg_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@color/blueLight" android:state_pressed="true"/>
<item android:drawable="@color/blueLight" android:state_selected="true"/>
<item android:drawable="@color/blueDark"/>
</selector>
bottom_tabs.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/realtabcontent"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" />
<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
</android.support.v4.app.FragmentTabHost>
</LinearLayout>
【问题讨论】:
-
你在使用 AppCompat 库吗?
-
是的,编译'com.android.support:appcompat-v7:22.1.0'
-
你能贴出tabvew的代码吗
-
完成,您现在可以查看。
标签: android android-actionbar-compat android-actionbar-tabs