【发布时间】:2013-08-06 14:33:42
【问题描述】:
问题如下:在我的一项活动中,我需要为我的操作栏自定义布局,而要做到这一点的唯一方法是在我的屏幕上设置一个透明的操作栏。为此,我将 ActionBar 标记为覆盖,并将操作栏背景指定为透明。这在使用 Android >= 15 时有效,但在 14 及以下版本中,ActionBar 保持其底部边框。我尝试了任何方法来删除它,但无济于事。
这里有一张图看得更清楚:
在 API 14 上:
在 API 16 上:
设计如下:Action Bar 应该是透明的,并且是覆盖模式,在它的后面有一个背景+logo
<ImageView
android:id="@+id/action_bar_background"
android:layout_width="match_parent"
android:layout_height="@dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:contentDescription="@string/action_bar"
android:scaleType="fitXY"
android:src="@drawable/actionbar_logo_extended" />
<ImageView
android:id="@+id/home_gallica_logo"
android:layout_width="@dimen/largeur_logo_carrousel"
android:layout_height="@dimen/action_bar_accueil_total_height"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:contentDescription="@string/action_bar"
android:src="@drawable/logo_fullcolor" />
一些精度:我使用 ABS,但这似乎不是问题的根源,因为切换到 v7 支持库做了完全相同的事情。
有人知道如何删除这个底部边框吗?
【问题讨论】:
-
嗯,我想这都是关于不同版本如何解释
.png图像。您可以将图像的背景设置为像背景的渐变。我将搜索我的假设。 -
事实上,ActionBar 应该是透明的(并且处于叠加状态),以便看到它下面的图像。
-
好吧,让我问你这个问题,为什么水平线在 API 16 上仅部分消失 - 图像那么长(宽度)?我还注意到,在 API 14 上,你在标志后面加了双线,你想要的消失了,但第二行是可见的。这让我想知道 - 你能把资源粘贴在这里以便我看到它们 - 徽标的图像(在平铺背景上,带有它的大小),你使用的图像(gradient.xml 或普通图像渐变) ActionBar + 整个
xml如果这不是问题? -
“第二条”水平线不是真实的:它是我放置在操作栏后面的图像的一部分。这就是为什么你可以在 API 14 和 16 中看到它。如果可以的话,我明天会尝试发布 XML
-
@g00dy :我添加了 XML 以便更清楚地解释
标签: android actionbarsherlock android-actionbar