Background Edittext Alpha (transparency)

Asked

Viewed 105 times

0

I would like to know how to make the Edittext fund transparent, in this way:

Campos

I tried in the following ways, but without success:

edt.xml

<?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" />
    <solid android:color="@color/editText_alpha" />
</shape>

Cor

And I tried to set it straight onCreate:

mEmailView.setAlpha(0.7f);

2 answers

0

I tested it here, and the transparence seems to work properly like this

<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

  • Weslley like this only works directly in Edittext. I needed it as a specific xml. I actually already got it. I’ll post.

  • I don’t understand, any XML you set the background will work, even in a style if you set the background every application will inherit

  • It could be ! I tried to pull only color, the background no! I am leaving all the style for the end ! Rs... Put in your reply by XML that I confirm and already confirm the answer. Thanks !

0


The only way it worked was to replace the shape by 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>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.