Android 在edittext上应用背景
我试图在Android 在edittext上应用背景,android,xml,android-studio,android-layout,Android,Xml,Android Studio,Android Layout,我试图在编辑文本上应用背景(一个可绘制的),但是可绘制的以某种方式获得了白色背景。这是我的可绘制的背景 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <stroke android:width="4sp" android:color="@android:colo
编辑文本
上应用背景(一个可绘制的
),但是可绘制的
以某种方式获得了白色背景。这是我的可绘制的背景
<?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>
<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>
以下是我想应用背景的编辑文本:
<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" />
这就是我得到的结果
我只希望可绘制的
应用为编辑文本的背景,而不是背景中的白色框。
<?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>
<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>
试试这个:
<?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>
尝试将笔划颜色更改为透明或黑色