Android透明属性在Android 4.1.1上不起作用

und*_*oid 2 android android-widget android-layout

我试图使透明ButtonseditTexts,我使用自定义xml文件,它按预期在Android 5上工作(所有字段确实透明),但是当使用Android 4.1.1在模拟器上运行相同的应用程序时,这些字段出现黑色.

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle"
    android:background="@android:color/transparent">
    <stroke android:width="3px" android:color="#FFF" />
</shape>
Run Code Online (Sandbox Code Playgroud)

如何在旧版Android操作系统上实现透明效果?

Mad*_*dhu 8

将背景设置为透明是工作api级别4.0以后在xml中添加以下行

 android:background="@android:color/transparent"
Run Code Online (Sandbox Code Playgroud)

或尝试这样的事情

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
<solid android:color="@android:color/transparent" />
    <stroke android:width="3px" android:color="#FFF" />
</shape>
Run Code Online (Sandbox Code Playgroud)