Background EditText Alpha (transparency)

1

I'd like to know how to make the EditText background transparent, like this:

Itriedthefollowingways,butwithoutsuccess:

edt.xml

<?xmlversion="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <corners android:radius="5dp" />
    <padding
        android:bottom="4dp"
        android:left="4dp"
        android:right="4dp"
        android:top="4dp" />
    <solid android:color="@color/editText_alpha" />
</shape>

And I tried to set right on onCreate :

mEmailView.setAlpha(0.7f);
    
asked by anonymous 07.02.2018 / 12:10

2 answers

0

The only way so far that has worked, has been to replace shape with a gradient

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools">
    <corners android:radius="5dp" />
    <padding
        android:bottom="4dp"
        android:left="4dp"
        android:right="4dp"
        android:top="4dp" />
    <gradient
        android:centerColor="#9CE9E9E9"
        android:endColor="#9CE9E9E9"
        android:startColor="#9CE9E9E9" />
</shape>
    
08.02.2018 / 19:54
1

I have tested here, and the transparency seems to work correctly so

<EditText      
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"//coloquei padding para criar espaçamento entre as extremidades e a letra
android:background="#6affffff" //Transaparencia pode ser adiciona aqui
android:hint="Texto da descrição" />

can be used tbm @android:color/transparent to get value 100% transaparente

    
08.02.2018 / 19:39