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

标签 android

我有一个进度条,我将其背景设置为透明。它适用于较新版本的 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。

任何想法如何使它透明?

最佳答案

这可能与您使用的主题有关。确保明确设置进度条下方 View 的颜色。

Holo Light 和 Holo Dark 为根元素设置了不同的默认背景,因此覆盖它们可能会解决您的问题。

http://developer.android.com/design/style/themes.html

关于android - 透明背景在 api 14-15 上显示为黑色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24875391/

相关文章:

android - jetpack compose 中禁用但可点击的开关

Java 优化 : (Hotspot/Dalvik) Optimization of final method returning a constant?

android - GestureDetector.onTouchEvent 中的 NullPointerException

javascript - 如何添加到Android移动设备的 'Add to homescreen'弹出窗口

android - 谷歌地图 Android V2 - 黑屏

java - 显示另一个 Activity 而不是 MainActivity

android - 使用 Phonegap 在 Android 上的媒体播放器中打开 RTSP 链接

android - 我们可以在 Android 中创建自定义 Synthetic Kotlin Extensions 吗?

android - 从与覆盖基本适配器android连接的 ListView 中获取选中的项目

java - 为什么我的 SQLite 数据库操作 "updateinformation2"没有更改我的 "name"值?