【发布时间】:2019-08-13 00:10:00
【问题描述】:
我应用了海拔属性和可绘制背景,为EditText View 提供了圆形轮廓,但没有预期的阴影。
<?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:layout_margin="20dp"
android:background="#FAFAFA"
tools:context=".MainActivity">
<EditText
android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="51dp"
android:layout_marginTop="52dp"
android:elevation="20dp"
android:background="@drawable/rounded_edittext"
android:drawableStart="@drawable/ic_search_icon"
android:drawableLeft="@drawable/ic_search_icon"
android:ems="10"
android:inputType="textPersonName"
android:paddingLeft="20dp"
android:paddingRight="20dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
</android.support.constraint.ConstraintLayout>
以及背景rounded_edittext.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#FFFFFF"/>
<corners
android:bottomRightRadius="27.5dp"
android:bottomLeftRadius="27.5dp"
android:topLeftRadius="27.5dp"
android:topRightRadius="27.5dp"/>
<stroke android:color="#66000000" android:width="0.5dp"/>
</shape>
更新
以下是原始设计。
【问题讨论】:
标签: android