android 画竖虚线

百般思念 提交于 2021-02-16 17:20:37

参考:http://blog.csdn.net/zhao2017/article/details/73866460

1.在Android中写横虚线比较简单,写竖虚线的话稍微麻烦点: 
需要将写的虚线旋转: 
这里面旋转角度设置为90 到90。

<rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:fromDegrees="90" android:toDegrees="90"> <shape android:shape="line"> <stroke android:width="1dp" android:color="#ebebeb" android:dashGap="1dp" android:dashWidth="2dp" /> <size android:width="200dp" android:height="3dp"></size> </shape> </rotate>
  •  

然后在用的地方可以将View的宽度设置的很大,以免周边的View影响其显示。

竖虚线在实际中用到的地方。

  <View
            android:id="@+id/view"
            android:layout_width="100dp" android:layerType="software" android:layout_height="match_parent" android:layout_marginLeft="-40dp" android:layout_marginRight="-10dp" android:layout_toRightOf="@id/tv_number" android:background="@drawable/main_red_pck_dash_line" > </View>
  •   

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!