android:如何在EditText视图上显示阴影?

android:如何在EditText视图上显示阴影?,android,Android,我应用了高程属性和可绘制的背景,为EditText视图提供了一个圆形轮廓,但没有预期的阴影 用以下代码替换舍入的\u edittext.xml: <layer-list xmlns:android="http://schemas.android.com/apk/res/android"> <item > <shape android:shape="rectangle"> <solid android:color

我应用了高程属性和可绘制的背景,为
EditText视图提供了一个圆形轮廓,但没有预期的阴影



用以下代码替换舍入的\u edittext.xml:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
    <shape
        android:shape="rectangle">
        <solid android:color="@android:color/darker_gray" />
        <corners android:radius="27.5dp"/>
    </shape>
</item>
<item android:right="1dp" android:left="1dp" android:bottom="2dp">
    <shape
        android:shape="rectangle">
        <solid android:color="#FFFFFF"/>
        <corners
            android:radius="27.5dp"/>
        <stroke android:color="#66000000" android:width="0.5dp"/>
    </shape>
</item>

另外,将
android:elevation=“20dp”
EditText替换为
android:elevation=“4dp”
转到此处:

或者,如果要在视图下放置阴影,请添加以下内容

在Layout.xml中

<View android:layout_width="match_parent"
    android:layout_height="5dp"
    android:background="@drawable/dropshadow"/>

drawble/dropshadow.xml>

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient android:startColor="@android:color/transparent"
        android:endColor="#88333333"
        android:angle="90"/>
</shape>


可能的重复在这种情况下,您不能直接将渐变应用为背景。您需要在
中添加渐变背景作为
。我不建议将其作为EditText背景,您必须在a的背景中添加渐变背景,以便在特定视图下产生某种效果,因此。。。另外,我没有使用多个项目,所以不需要放入和,通过放入一些xml文件并首先使用它来尝试这段代码。