android利用xml实现分割线
作者:学习编程知识
这篇文章主要介绍了android利用xml实现分割线的方法,如何用xml产生一个分割线?感兴趣的小伙伴们可以参考一下
因为没有美工, 所以只能自己动手了。
在layout文件夹里的xml 写
方法1:在layout里面的布局xml 文件里加上面的代码
<View android:layout_width="match_parent" android:layout_height="1dp" android:background="@color/orange_normal" />
效果图
在drawable文件夹里用 shape line 或 rectangle 先画线
方法2:在drawable里面用shape新建一个xml
然后在 layout 里的布局文件里引用
这种方法 可以 多处引用同一个 line 样式
<!-- drawable/line_my.xml --> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="line" > <stroke android:color="@color/orange_normal" /> </shape>
或者用填充的矩形实现
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <solid android:color="@color/orange_normal" /> <size android:height="1dp" android:width="100dp" /> </shape>
Note
android:width=”100dp” 不能赋值为 “match_parent”
在layout/bomb_fragment.xml 里面引用
<TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/line_my" />
希望本文所述对大家学习Android软件编程有所帮助。
您可能感兴趣的文章:
- Android中控件GridView实现设置行列分割线的方法示例
- Android自定义DataGridView数据表格控件
- Android RecyclerView网格布局(支持多种分割线)详解(2)
- android shape的使用及渐变色、分割线、边框、半透明阴影
- 详解Android中ListView实现图文并列并且自定义分割线(完善仿微信APP)
- Android RecyclerView实现水平、垂直方向分割线
- Android修改DatePicker字体颜色及分割线颜色详细介绍
- android中RecyclerView自定义分割线实现
- Android实现RecyclerView添加分割线的简便方法
- Android使用GridView实现表格分割线效果