Android 虚线出不来的问题解决方法
来源:互联网 发布:大数据时代到来 编辑:程序博客网 时间:2024/06/08 06:10
有些时候需求要我们画一条虚线,效果图是这样的
我们一般会这样写
dashed_line.xml 文件
<?xml version="1.0" encoding="utf-8"?><shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line"> <stroke android:width="1dp" android:color="@color/huise" android:dashGap="8dp" android:dashWidth="8dp" /></shape>
然后在布局文件中引用
<View android:layout_width="match_parent" android:layout_height="1.5dp" android:background="@drawable/dashed_line" android:layout_marginTop="20dp"/>
却发现出来的结果是这样的,没错,直接一条实线就出来了这个是因为从安卓3.0开启,提供了硬件加速功能,导致的这个bug。我们只要把硬件加速关闭就可以了。但是关闭整个app或者关闭整个activity的硬件加速,好像不太合适。所以我们只设置我们的虚线不启用硬件加速
所以在引用的地方加上这么一句
<View android:layout_width="match_parent" android:layout_height="1.5dp" android:background="@drawable/dashed_line"
android:layerType="software"
android:layout_marginTop="20dp"/>
就可以了。效果就出来了
0 0
- Android 虚线出不来的问题解决方法
- Android实现虚线的方法
- Android的虚线,虚线和实现并存
- flex画虚线的方法
- ios画虚线的方法
- Android遇到的问题解决方法
- Android之虚线的实现
- Android 画虚线的问题
- Android画虚线的问题
- Android里面的竖虚线
- MS Visio虚线框粘贴出来是实线的问题解决
- android虚线
- Android虚线
- android虚线
- Android 虚线
- 网上的常见的画虚线方法~
- 去掉flash四周虚线框的方法
- mac 下绘制虚线的方法
- LeetCode笔记:394. Decode String
- 上传List集合 (List<实体类>转json)
- CentOS7禁用防火墙相关命令
- Maven 项目打包
- HIVE中NULL值的处理
- Android 虚线出不来的问题解决方法
- python中lambda表达式中自由变量的坑
- 每天一个Linux命令(29):gzip
- TCP与UDP
- java 幂等性
- 猴子理论——高效管理的一种方式
- 如何逆向逐层输出树中的元素
- POJ 3070 Fibonacci
- TLS协议分析 (七) 安全性分析