[英]How to change the background color of the tabs in the action bar?
如何更改應用程序操作欄中的選項卡顏色。
標簽:
當前代碼以添加標簽:
private void addTabs(ActionBar actionBar)
{
ActionBar.Tab tab1=actionBar.newTab();
tab1.setText("All");
tab1.setTabListener(this);
ActionBar.Tab tab2=actionBar.newTab();
tab2.setText("Technology");
tab2.setTabListener(this);
ActionBar.Tab tab3=actionBar.newTab();
tab3.setText("Business");
tab3.setTabListener(this);
actionBar.addTab(tab1);
actionBar.addTab(tab2);
actionBar.addTab(tab3);
}
一種方法是創建一個自定義主題xml文件,該文件在values文件夾下設置。 例如,在名為Example的主題中,如果已准備好繪制,則可以使用以下代碼,也可以使用顏色。
<style name="ActionBarTabStyle.Example" parent="@android:style/Widget.Holo.ActionBar.TabView"> <item name="android:background">@drawable/tab_indicator_ab_example</item> </style>
我建議您訪問Android操作欄樣式生成器,因為它可以非常輕松地設置操作欄和標簽的樣式,並節省一些時間。
不要忘記在您的android manifest xml文件下更改主題。
希望這可以幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.