我需要让我的 EditText 看起来像下图一样有深度。
我有这个形状我不知道要添加什么
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners android:radius="50dp" />
<solid android:color="@color/primary_dark" />
</shape>
最佳答案
你可以用这样的 drawable
来完成:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--background to compensate the transparency under shadow and glow (for bigger depth values)-->
<item>
<shape android:shape="rectangle">
<corners android:radius="50dp" />
<solid android:color="@color/primary_dark" />
</shape>
</item>
<!--top, dark, inner shadow-->
<item
android:bottom="@dimen/depth">
<shape android:shape="rectangle">
<corners android:radius="50dp" />
<solid android:color="#1A000000" />
</shape>
</item>
<!--bottom, light, outer glow-->
<item
android:top="@dimen/depth">
<shape android:shape="rectangle">
<corners android:radius="50dp" />
<solid android:color="#4DFFFFFF" />
</shape>
</item>
<!--your color-->
<item
android:top="@dimen/depth"
android:bottom="@dimen/depth">
<shape android:shape="rectangle">
<corners android:radius="50dp" />
<solid android:color="@color/primary_dark />
</shape>
</item>
</layer-list>
并在dimens.xml
中定义一个dimen
<dimen name="depth">2dp</dimen>
通过改变dimen
你可以改变drawable
的深度
关于android - 如何为形状添加深度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28110227/