Problem with 9 patch image as background

…衆ロ難τιáo~ 提交于 2019-11-30 13:05:55

Since nobody answered you for a year now... I had the same issue you need to setpadding of zero (even if you don't need it).

Good luck.

You can use nine patch in the same way you use a normal drawable. I assume you have a problem with the 9 patch itself. In the /tools directory of your android sdk you have the draw 9 patch tool. It will help you to correct your 9 patch drawable and to preview it for different sizes of your view.

select all sides except corners as the stretching edges

you can use this xml as background to show as cardview.

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
    <shape android:dither="true" android:shape="rectangle">
        <corners android:radius="2dp" />
        <solid android:color="#e2e2e2" />
    </shape>
</item>
<item android:bottom="2dp">
    <shape android:dither="true" android:shape="rectangle">
        <corners android:radius="2dp" />
        <solid android:color="@color/white" />
    </shape>
</item>

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