Применение фона к тексту редактирования - PullRequest
0 голосов
/ 13 ноября 2018

Я пытаюсь применить фон (Drawable) к EditText, но Drawable каким-то образом получает белый фон.Вот мой Drawable фон.

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

    <stroke
        android:width="4sp"
        android:color="@android:color/white" />

    <corners android:radius="20dp" />
    <solid android:color="@color/colorPrimary"/>

</shape>

Вот EditText, к которому я хочу применить фон:

   <EditText
        android:id="@+id/mEditTextSearch"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/drawable_search_back"
        android:padding="10dp"
        android:visibility="visible" />

Это результат, который я получаю.

The result

Я просто хочу, чтобы Drawable применялся в качестве фона для EditText, а не для белого поля на фоне.

Ответы [ 2 ]

0 голосов
/ 13 ноября 2018

попробуйте это:

<?xml version="1.0" encoding="utf-8"?>
    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@color/colorPrimary"
        tools:context=".MainActivity">

        <EditText
            android:id="@+id/mEditTextSearch"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/drawable_search_back"
            android:layout_margin="10dp"
            android:visibility="visible" />

    </android.support.constraint.ConstraintLayout>
0 голосов
/ 13 ноября 2018
 <RelativeLayout
        android:background="@drawable/drawable_search_back"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    <EditText

        android:id="@+id/Name"
        android:inputType="text"
        android:hint="Name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"/>
    </RelativeLayout>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...