Android L is not able to draw dotted line as drawable background

痴心易碎 提交于 2019-12-23 10:59:09

问题


Android L is not able to draw dotted line as drawable background as below:

<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item> 
<shape  android:shape="line" >

    <stroke
        android:dashGap="1dp"
        android:dashWidth="1dp"
        android:color="#999999" />

    <size android:height="1dp" />

    </shape>
</item>
</selector>

I am also using layerType='software' in xml. Kindly help.


回答1:


1.The view must be at least 2dp in height (or wrap_content), in order for it to display since a stroke is designed to go around the view and it doesn't have room to do so in 1dp.

2.Add width to your xml:

<stroke
    android:width="1dp"
    android:dashGap="1dp"
    android:dashWidth="1dp"
    android:color="#999999" />

<size android:height="1dp" 
    android:width="1dp"/>

3.Use layerType='software'



来源:https://stackoverflow.com/questions/24536617/android-l-is-not-able-to-draw-dotted-line-as-drawable-background

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