android - 摆脱蓝线

标签 android android-actionbar actionbarsherlock android-theme

在 ActionBarSherlock 的帮助下,我尝试让我的应用程序在 3.0 之前的设备上运行。操作栏中有一个蓝色分隔线,我想将其移除。

strange blue line

我发现它不是分隔线,而是操作栏背景图形的一部分。为了摆脱蓝线,我决定像这样覆盖背景:

 <style name="MyActionBar" parent="android:Widget.Holo.ActionBar">
   <item name="android:background">@drawable/black</item>
   <item name="background">@drawable/black</item>
 </style>

我也在Java代码中设置了背景:

getSupportActionBar().setStackedBackgroundDrawable(this.getResources().getDrawable(R.drawable.black));

因此,蓝线在 4.x 设备上消失了,但在 2.3.x 设备上仍然可见。如何去除 2.3.x 设备上的蓝线?

最佳答案

愚蠢的错误:我使用了 setStackedBackgroundDrawable 而不是 setBackgroundDrawable。它适用于 setBackgroundDrawable。这是设置操作栏背景的正确方法。 setStackedBackgroundDrawable 设置标签栏的背景。

关于android - 摆脱蓝线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16539251/

相关文章:

android - 如何使用 Android View Pager + ActionBar 选项卡将 View 发送到 Google Analytics?

android - 无法隐藏操作栏 Logo

android - Fragment 上的 ViewPager 中的 Fragment 不会在方向更改时重新加载

java - 成功使用Android通过HDMI控制外接显示器

android - Unresolved reference DaggerApplicationComponent

android - ActionBar 背景与 MaterialComponents 主题

Android操作栏选项卡: screen rotation

android - 为什么 isItemChecked() 在 ActionMode 中返回 true?

android - 找不到apk文件

android - 如何在android map 中设置 map 聚类的半径