源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

android利用xml实现分割线

  • 时间:2020-08-27 23:01 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:android利用xml实现分割线
因为没有美工, 所以只能自己动手了。 在layout文件夹里的xml 写 [b]方法1:[/b][b]在layout里面的布局xml 文件里加上面的代码[/b]
 <View
 android:layout_width="match_parent"
 android:layout_height="1dp"
 android:background="@color/orange_normal" />
效果图 [img]http://files.jb51.net/file_images/article/201512/20151230150544831.jpg?2015113015553[/img] 在drawable文件夹里用 shape line 或 rectangle 先画线 [b]方法2:[/b][b]在drawable里面用shape新建一个xml[/b] 然后在 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>

[b]Note [/b] 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软件编程有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部