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

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

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

[html]  view plain  copy
  1. <View  
  2.         android:layerType="software"    
  3.         android:layout_width="match_parent"  
  4.         android:layout_height="3dp"  
  5.         android:background="@drawable/dotted_line" />  
[html]  view plain  copy
  1. dotted_line.xml文件  
[html]  view plain  copy
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:shape="line" >  
  4.     <stroke  
  5.         android:dashGap="3dp"  
  6.         android:dashWidth="3dp"  
  7.         android:width="1dp"  
  8.         android:color="#2f000000" />  
  9.     <size android:height="1dp" />  
  10. </shape>  
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值