android 画竖虚线

参考: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>
  •   

 

posted @ 2018-01-19 19:59  manmanlu  阅读(1089)  评论(0编辑  收藏  举报