android - 如何完全删除 ActionBar 中的选项卡指示器

标签 android android-actionbar

我在我的 FragmentActivity(最小 SDK = 14)中使用了一个 ActionBar,我需要删除 Activity 的 Tab 指示器(见下图),因为我有自己的图标用于指示哪个选项卡处于 Activity 状态。我一直在阅读很多与样式相关的东西,但是没有找到解决方案。有什么建议可以完全删除这个指标吗?

enter image description here

已解决

工作解决方案如下:

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

然后添加到 Activity 样式中:

<item name="android:actionBarTabStyle">@style/ActionBarTabStyle</item>

最佳答案

来自 How to change the color of tab 'underbar' in actionbarsherlock , 看起来指示器是可绘制对象的一部分。我没试过,但你可能可以将 @drawable/tab_selected 和 @drawable/tab_selected_focused 更改为你自己的 drawable。 (如果您不想要指示器,请说清楚。)希望这对您有所帮助。

编辑:

注意:尚未测试

您可以尝试关注 the answer并从 tab_selected_focused 更改为 tab_unselected_focused,也从 tab_selected 更改为 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" />

编辑 2: 您可以尝试 ActionbarStyleGenerator 来设置 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"

关于android - 如何完全删除 ActionBar 中的选项卡指示器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18384727/

相关文章:

android - 具有背景颜色和文本的回收器 View 滑动不在滑动时显示矩形

android - 如何更改 EditText 中光标的外观?

Android:像股票浏览器一样的 ActionBar

android - Action 模式关闭按钮文字颜色

c# - Android 手机作为 GSM 调制解调器

android - 现在比较日期时间的 SQLite 只比较日期

android - Android 开发者控制台中的神秘堆栈跟踪(位图大小超过 32 位)

android - 无法将自定义 View 添加到 Android 操作栏,为什么?

android - 在 XML 中将 ActionBar 背景颜色设置为 colorPrimary 以外的颜色

android - ActionBar 菜单项选择器