Tôi đang gặp khó khăn với việc tạo kiểu cho ActionBar. Ứng dụng của tôi có một ActionBar với ba tab. Tôi đang cố gắng để có được tab được chọn để có màu nền và các tab không được chọn để hiển thị màu khác. Tôi đang theo dõi tham chiếu này: Customizing Action Bar. Nhưng tất cả các TAB đều hiển thị màu đã chọn.Cách tạo StyleBar, nền tab trên tab đã chọn
tập tin styles.xml
của tôi là như sau:
<style name="MyActionBarTabStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">@drawable/tab_background</item>
<item name="android:paddingLeft">32dp</item>
<item name="android:paddingRight">32dp</item>
</style>
<style name="MyActionBarTabBarStyle" parent="android:style/Widget.Holo.Light.ActionBar.TabBar">
<item name="android:background">@drawable/red</item>
</style>
<style name="AppTheme.Light" parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/ActionBar.Light</item>
<item name="android:actionBarTabStyle">@style/MyActionBarTabStyle</item>
<item name="android:actionBarTabBarStyle">@style/MyActionBarTabBarStyle</item>
</style>
tab_background chỉ là một bản vá 9. Tôi cũng không chắc liệu tôi có kế thừa tab thanh tác vụ từ cha mẹ chính xác hay không (parent="android:style/Widget.Holo.Light.ActionBar.TabBar
). Tôi đã xem qua các tài liệu tham khảo & thấy rất khó hiểu cấu trúc phân cấp kiểu
Tại sao các tab của tôi không hiển thị được chọn hay không? Cảm ơn trước sự giúp đỡ của bạn.
Sử dụng [ActionBarSherlockStyleGenerator] (http://jgilfelt.github.com/android-actionbarstylegenerator/ # name = example & compat = holo & theme = light & actionbarstyle = solid & backColor = E4E4E4,100 & secondaryColor = D6D6D6,100 & tertiaryColor = F2F2F2,100 & accentColor = 33B5E5,100) để tạo kiểu và sử dụng. Kiểm tra câu trả lời của tôi [ở đây] (http://stackoverflow.com/questions/13269482/change-background-of-the-actionbarsherlock-alone-not-the-tabs/13283261#13283261) – PravinCG
Cảm ơn Pravin. ActionBarStyleGenerator rất hữu ích để tạo kiểu ActionBar – CocoNess