android使用xml实现虚线效果
2015-07-10 16:40
519 查看
废话不多说,先上效果图:
android下面实现虚线可以使用xml来写。
在res的drawable目录下创建dashed_line.xml
写上如下代码:
下面代码片段是我在界面上对虚线的使用:
android下面实现虚线可以使用xml来写。
在res的drawable目录下创建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="#CCCCCC" android:dashGap="3dp" android:dashWidth="6dp"/> <!--dashGap 为两个短虚线间的宽度--> <!--dashWidth 为短虚线的宽度--> </shape>
下面代码片段是我在界面上对虚线的使用:
<LinearLayout android:gravity="center_vertical" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <!--android4.0以上需要添加android:layerType="software"属性,否则会显示为实线,有兴趣的朋友可以测试一下--> <View android:layerType="software" android:layout_weight="1" android:background="@drawable/dashed_line" android:layout_width="0dp" android:layout_height="2dp"/> <TextView android:text="Or" android:textColor="#ffc7c7c7" android:textSize="@dimen/textSize_18" android:padding="15dp" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <View android:layerType="software" android:layout_weight="1" android:background="@drawable/dashed_line" android:layout_width="0dp" android:layout_height="2dp"/> </LinearLayout>到此结束。。。。。。
相关文章推荐
- MAC OS X10.10上Android开发环境搭建
- Android手机安全卫士(二)---设置、自定义控件属性、md5加密、手机防盗
- Dalvik虚拟机中RegisterMap结构解析
- Android 的gallery控件
- android listview滑动过程中不加载图片,停止时加载图片。
- android 杀不死的服务 ,主要是即时通讯,通知及时传送
- Android开发:带动画的分享效果
- android studio常用设置
- Android 双卡双待
- Android Wifi --自动连接指定SSID(各种加密方式均可)
- 关于android中PendingIntent.getBroadcase的注册广播
- Android实现圆角边框
- Android Selector 与 Shape 基本用法
- android的SQLite介绍
- android的parcelable接口
- android edittext只能输入字母和数字,默认弹出英文输入法
- Android_开源控件_DragSortListview
- android中定时任务的两种实现
- Android接口测试-JUnit入门
- 解决Android SDK Manager国内更新不了问题