android shape 画虚线
项目中某些布局可能有这样的需求,画一条虚线作为分割线
1.先写一个shape,命名为shape_line_dash.xml
<?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:width="@dimen/dp1"
android:color="#f00"
android:dashGap="@dimen/dp2"
android:dashWidth="@dimen/dp4"/>
</shape>
2.再在布局文件中写一个View,引用第一步中的shape
<View
android:layerType="software"
android:layout_width="match_parent"
android:layout_height="@dimen/dp2"
android:layout_marginLeft="@dimen/dp17"
android:layout_marginRight="@dimen/dp17"
android:background="@drawable/shape_line_dash"/>
注意:
软加速
1.引用的时候,View的height要大于shape中stroke的width,不然会显示不出来,或者显示不全。
2.还要设置一个属性layerType为software,不然显示出来的是实线。
android shape 画虚线相关推荐
- android 虚线画不出来的,Android shape画虚线,不显示或者显示是实线的解决方案
Android 的 shape可以用来实现一些简单的图像,如直线(实线.虚线).圆.矩形.圆角矩形.边框等. 4.4以及以前的版本shape是能正常显示一条虚线的,最经碰到在5.0的手机上显示的是直线 ...
- android shape画虚线
横着的虚线 <View android:layout_width="match_parent" android:layout_height="@dimen/base ...
- Android shape画虚线,不显示或者显示是实线的解决方案
Android 的 shape可以用来实现一些简单的图像,如直线(实线.虚线).圆.矩形.圆角矩形.边框等. 4.4以及以前的版本shape是能正常显示一条虚线的,最经碰到在5.0的手机上显示的是直线 ...
- Android shape画虚线,不显示或者显示实线的解决方案
// shape.xml中的代码<?xml version="1.0" encoding="utf-8"?> <shape xmlns:and ...
- android用shape画虚线,怎么也不显示
一直以为android的shape能画直线,虚线,矩形,圆形等,画直线也就算了,用一个view设一下高度和颜色,就可以出来一条直线了.所以说这个对我来说经常不用,圆形是可以,看看我应用里的消息提 ...
- android path 画虚线,Android实现画虚线的控件
在Android的UI开发中,有时为了界面美观而需要虚线.我自己实现一个虚线控件. package com.custom; import android.content.Context; import ...
- Android drawLine 画虚线
drawLine 是画线的 ,有时候想画虚线可以使用 PathEffect 代码如下 Paint linePaint = new Paint();linePaint.reset();linePaint ...
- android shape画边框,安卓用shape画圆角矩形边框
效果图: 代码: 一.xml方式 代码: shape_rec_blue.xml 圆角矩形边框 android:shape="rectangle"> android:width ...
- android shape 画阴影_Android使用shape绘制阴影图层阴影效果示例
最近在项目中用到一个比较有意思的阴影特效 从上面的效果图上可以发现在图片的右.下有一个阴影的特效,通过这个阴影效果明显会使得这个提示文本有一种立体的观感.瞬间高大上有木有? 基于以上UI效果,有两种最 ...
最新文章
- java游戏移动_java - Java游戏 - 如何让敌人移动? - SO中文参考 - www.soinside.com
- C语言求3x3数组对角线元素之和
- spring+kafka消费者的2种配置方式
- 如何汉化DNN--中文语言包的使用
- android edittext不可复制_Android EditText禁止复制粘贴
- springboot 加载mybatis的流程
- 4行代码满分:L1-052 2018我们要赢 (5分)
- linux 线程带参数,Linux中多线程编程并传递多个参数的简单例子
- python超时处理_Python如何实现让一个函数超时退出?
- TensorFlow中的Keras用法和自定义模型和层
- python决策树画图_利用python用iris做一个决策树的可视化更好的理解机器学习!...
- linux运行Windows模拟器,如何安装和使用Wine,以便在Linux上运行Windows应用程序?...
- USBCNC导入DXF文件
- es - elasticsearch search - missing value and unmapped fields
- HikariPool-1 - Exception during pool initialization. Could not create connection
- 中国服务外包行业发展现状与前景趋势分析报告2022-2028年版
- PHP中date时差问题解决方法
- sql语句查询一天24小时每个小时数据,查询时间段内每天数据
- 树莓派自定义分辨率适配带鱼屏(2560*1080)
- 努力和天赋哪个更重要