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>

更多相关文章

  1. Android Activity启动模式设置为SingleTask需要注意的地方
  2. Android实现代码画虚线边框背景效果
  3. android在XML中画横线、竖线和虚线
  4. Android中shape 横线+竖线~虚线
  5. 关于android示例程序(bitmapfun)——高效加载图片的坑爹地方
  6. android 画虚线不显示解决方案

随机推荐

  1. Android的ADB工具使用
  2. android背景选择器selector用法、自定义B
  3. [置顶] Android曙光集群发来的邀请函
  4. Android(安卓)UI布局之LinearLayout
  5. ArcGIS API for Android(安卓)案例教程 1
  6. android实现自动对焦拍照
  7. Android应用程序与SurfaceFlinger服务的
  8. Android(安卓)Stagefright
  9. Android书籍分享
  10. RelativeLayout中常用属性解释