Designing EditText with rounded corners & inner shadow

喜夏-厌秋 提交于 2019-12-09 16:44:53

问题


I'm trying to create a custom EditText that has both rounded corners and an inner shadow.

I made a layer list that creates the inner shadow,

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">

    <item >
        <shape android:shape="rectangle">
            <solid android:color="#6C6C6C" />           
        </shape>
    </item>

    <item>
        <shape android:shape="rectangle">
            <solid android:color="@color/ashes" />   
        </shape>
    </item>

    <!-- White Top color -->
    <item android:top="3px" android:left="3px">
        <shape android:shape="rectangle">
            <solid android:color="#FFFFFF" />           
        </shape>
    </item> 
</layer-list>

The output looks like this,

How can I also add a rounded shape?


回答1:


Add a corners tag inside your shape tags:

  <corners
      android:radius="5dp" />


来源:https://stackoverflow.com/questions/24537517/designing-edittext-with-rounded-corners-inner-shadow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!