问题描述:
用以下代码绘制虚线:
<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <!--显示一条虚线,破折线的宽度为dashWith,破折线之间的空隙的宽度为dashGap,当dashGap=0dp时,为实线 --> <stroke android:dashGap="3dp" android:dashWidth="3dp" android:width="1dp" android:color="#dcdcdc" /> <!-- 虚线的高度 --> <size android:height="1dp" /> </shape>
在布局文件中引用画虚线的代码如下:
<ImageView android:layout_width="match_parent" android:layout_height="2dip" android:layout_margin="5dip" android:background="@drawable/dotted_line" />
在adt自带的graphical layout视图中的图形是:
没有问题,但是运行到手机上却变成了一条实线!!!,有木有!!!
解决方案:
找到工程的androidmanifest.xml文件,在application标签中添加属性值(禁用硬件加速),如下:
然后再次运行代码,问题解决!
版权声明:本文为博主原创文章,未经博主允许不得转载。
"Android使用Shape绘制虚线,在4.0以上的手机显示实线"解决方案
原文地址:http://blog.csdn.net/bear_huangzhen/article/details/46985129