透明背景在API 14-15上显示为黑色

5

我有一个进度条,我将其背景设置为透明。它在较新版本的Android上工作正常,但在14和15上显示为黑色。这是我的布局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".RaceActivity" >
<ProgressBar
    android:id="@+id/speedometer_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/speedometer_title" 
    android:layout_below="@id/current_distance_title" 
    android:padding="8dp" 
    android:background="@android:color/transparent"
    android:progressDrawable="@drawable/speedometer_progress_bar" 
    style="@android:style/Widget.ProgressBar.Horizontal"/>    

</RelativeLayout> 

我的应用程序主题是android:Theme.Holo.Light.DarkActionBar。

有什么想法可以使它透明吗?


可能是应用程序主题是黑色的,因此尽管进度条具有透明度,但容器元素具有黑色背景。 - stevebot
感谢您的帮助,stevebot。我已回复了答案。 - yaronbic
2个回答

1

5
尽管我不确定这是否是正确答案,但我标记了此答案为正确。我最终编辑了 @drawable/speedometer_progress_bar,它是一个层列表,底部项为 @android:id/background 。由于某种原因,在 Android 的 API 17 或更高版本中,它是透明的,但在 16 或更低版本中是黑色的,可能与主题有关。我在该项中添加了 <solid android:color="@android:color/transparent" />,问题得到解决。谢谢你的帮助。 - yaronbic

0

你可以使用 #00FFFFFF 颜色代替 @android:color/transparent
这对我起作用了。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接