2

J'ai quelques problèmes pour rendre un EditText transparent. Voilà ce que je veux: enter image description hereEditText définir l'opacité de l'arrière-plan

J'ai essayé:

  • Appliquer fond à editText avec la forme personnalisée:

    <?xml version="1.0" encoding="utf-8"?> 
    <shape xmlns:android="http://schemas.android.com/apk/res/android" 
        android:shape="rectangle" android:padding="10dp"> 
        <solid android:color="@color/transparentButton"/> 
        <!-- this one is this color of the Rounded Button --> 
        <corners 
        android:bottomRightRadius="0dp" 
        android:bottomLeftRadius="0dp" 
        android:topLeftRadius="0dp" 
        android:topRightRadius="0dp"/> 
    </shape>` 
    
    <color name="transparentButton"> #4CFFFFFF </color> 
    
    <EditText 
        android:id="@+id/usernameLoginTxt" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:drawableLeft="@drawable/ic_username_login" 
        android:drawablePadding="15dp" 
        android:background="@drawable/editetextbackground" 
        android:ems="10" 
        android:inputType="textPersonName" 
        android:hint="Username" 
        android:textColorHint="@color/black" 
        android:layout_marginLeft="8dp" 
        app:layout_constraintLeft_toLeftOf="@+id/titreLogin" 
        android:layout_marginRight="0dp" 
        app:layout_constraintRight_toRightOf="@+id/titreLogin" 
        android:layout_marginTop="44dp" 
        app:layout_constraintTop_toBottomOf="@+id/soustitrelogin"/> 
    

Mais avec cette méthode, la taille est réduite comme vous peut voir: enter image description here

  • J'ai essayé SetAlpha aussi, mais tout est transparent, editText, icône et texte

Merci pour votre aide, je souhaite que vous me comprendrez.

+0

essayer android: background = "null @" – chirag90

Répondre

2

Essayez ce module complémentaire android:padding="10dp" à votre EditText comme celui-ci

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:padding="10dp" 
    android:hint="Nilesh Rathod" 
    android:drawablePadding="10dp" 
    android:layout_marginTop="10dp" 
    android:background="@drawable/edittext" 
    android:drawableLeft="@drawable/ic_cart" /> 

drawable/edittext fichier

<?xml version="1.0" encoding="utf-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android" 
    android:padding="10dp" 
    android:shape="rectangle"> 

    <solid android:color="#c0d7d0d0" /> <!-- this one is ths color of the Rounded Button --> 

</shape> 
+0

Merci ça marche! Je pensais que je l'avais mis mais c'était juste en forme, alors j'ai accepté ta réponse! – Jamesp