Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android transparent property does not work on Android 4.1.1

Im trying to make transparent Buttons and editTexts, I'm using a custom xml file, it works on Android 5 as expected (all fields are indeed transparent), but when running the same app on the emulator using Android 4.1.1, these fields appear black.

<?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>

How can the transparency effect be achieved on older android OS's?

like image 205
Alex Avatar asked Jan 29 '26 03:01

Alex


1 Answers

Setting background as transparent is working api level 4.0 onwards add below line in your xml

 android:background="@android:color/transparent"

or Try some thing like this

<?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>
like image 186
Madhu Avatar answered Jan 30 '26 20:01

Madhu