android开发中解决shape画虚线时,在手机上显示实线的问题

使用shape绘制虚线时,在xml布局中显示的是虚线,在手机上运行起来却是实线,网上说是android4.0以上默认把Activity的硬件加速打开了,在Manifest.xml中关掉即可
</pre><pre name="code" class="html"><activity ...<span style="font-family: Arial, Helvetica, sans-serif;">android:hardwareAccelerated="false"/></span>

试了之后发现没效果,最终的解决方案是在view中把layerType设置成software

<View
        android:layerType="software"  
        android:layout_width="match_parent"
        android:layout_height="3dp"
        android:background="@drawable/dotted_line" />
dotted_line.xml文件
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="line" >
    <stroke
        android:dashGap="3dp"
        android:dashWidth="3dp"
        android:width="1dp"
        android:color="#2f000000" />
    <size android:height="1dp" />
</shape>




评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值