Create shape for drawable

谁说我不能喝 提交于 2019-12-12 10:08:11

问题


I have ListView, and i have a background for the list items:

Is there any way to recreate this background as a shape in drawable XML? The most outer grey is not part of the item background, it is actually the ListView.


回答1:


You can try following with the values of your choice. It will make the bottom two corners rounded.

rounded_rectangle.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">   
    <item>
    <shape>
        <gradient android:angle="270" android:endColor="#404040"              android:startColor="#404040" />
        <stroke android:width="1dp" android:color="#808080" />
        <corners android:bottomLeftRadius="11dp" android:bottomRightRadius="11dp"/>
    </shape>
    </item>
</selector>

then use it as a background to your listitem as follows

android:background="@drawable/rounded_rectangle"



回答2:


You can try this shape drawable:

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#606060"/>
    <stroke android:color="#303030" android:width="2dp" />
</shape>


来源:https://stackoverflow.com/questions/18653391/create-shape-for-drawable

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