Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
821 views
in Technique[技术] by (71.8m points)

android - how to completely remove tab indicator in an ActionBar

I use an ActionBar in my FragmentActivity (min SDK = 14) and I need to remove the active Tab indicator (see picture below) since I have my own icons for indicating which Tab is active. I've been reading a lot of style-related stuff, found no solution however. Any suggestions how this indicator can be completely removed?

enter image description here

SOLVED

The working solution is below:

      <style name="ActionBarTabStyle" parent="@android:style/Widget.Holo.ActionBar.TabView">
    <item name="android:background">@android:color/transparent</item>
</style>

and then adding to the Activity style:

<item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

From How to change the color of tab 'underbar' in actionbarsherlock, looks like the indicator is a part of a drawable. I haven't tried that but you probably can change @drawable/tab_selected and @drawable/tab_selected_focused to your own drawable. (Make it plain if you don't want the indicator.) Hope this helps.

Edit:

NOTE: HAVEN'T TESTED

You can try following the answer and change from tab_selected_focused to tab_unselected_focused and also from tab_selected to tab_unselected.

<!-- Non focused states -->
<item android:state_focused="false" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected" />
<item android:state_focused="false" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_unselected" />

 <!-- Focused states -->
 <item android:state_focused="true" android:state_selected="false" android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused" />
 <item android:state_focused="true" android:state_selected="true"  android:state_pressed="false" android:drawable="@drawable/tab_unselected_focused" />

Edit 2: You can try ActionbarStyleGenerator to style the Actionbar.

"How to: Use the UI to select colors for different items Once done click on "DOWNLOAD .ZIP" The ZIP file contains resource files that you have to copy in your project res/layout and res/drawableXXXX folders"


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...