介绍
本篇文章给大家分享的是有关怎么在android中绘制多个黑竖线条,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。
1。写一个LinearLayout的布局,将宽度写成5 dp将高度写成match_parent。
2。在写一个类继承LinearLayout,用LayoutInflater实现子布局的在这个LinearLayout类中显示.
3 .直接在需要使用的xml文件中调用我们写的这个类,注意路径要写全,
1。xml代码
& lt; ? xml version=?.0“,编码=皍tf-8" ?祝辞, & lt; LinearLayout  xmlns: android=癶ttp://schemas.android.com/apk/res/android",, ,android: layout_width=? dp", ,android: layout_height=癿atch_parent", ,android:背景=? 000000“, 在大敌; , & lt;/LinearLayout>
2。java代码
package com.example.lenovo.myfragmentdemo3;, , import android.content.Context, import android.support.annotation.Nullable, import android.util.AttributeSet, import android.view.LayoutInflater, import android.widget.LinearLayout, , import com.example.lenovo.myfragmentdemo3.R, ,/* *, ,* Created by  lenovo 提醒2018/5/7又是; ,*/, public class  Linedemo extends LinearLayout  {, ,public Linedemo (Context 上下文,@Nullable AttributeSet attrs), {, ,超级(上下文,attrs);, ,LayoutInflater.from(上下文).inflate (R.layout.line,),, }大敌; }
3。布局代码
& lt; ? xml version=?.0“,编码=皍tf-8" ?祝辞, & lt; LinearLayout  xmlns: android=癶ttp://schemas.android.com/apk/res/android",, ,android:取向=癶orizontal", ,android: layout_width=癿atch_parent", ,android: layout_height=癿atch_parent", ,android:填充=?0 dp", 在大敌; ,& lt; com.example.lenovo.myfragmentdemo3.Linedemo ,android: layout_width=?0 dp", ,android: layout_height=癿atch_parent", ,android: layout_marginRight=?00 dp"/祝辞, ,& lt; com.example.lenovo.myfragmentdemo3.Linedemo ,android: layout_width=?0 dp", ,android: layout_height=癿atch_parent", ,android: layout_marginRight=?00 dp"/祝辞, ,& lt; com.example.lenovo.myfragmentdemo3.Linedemo ,android: layout_width=?0 dp", ,android: layout_height=癿atch_parent", ,android: layout_marginRight=?00 dp"/祝辞, ,& lt; com.example.lenovo.myfragmentdemo3.Linedemo ,android: layout_width=?0 dp", ,android: layout_height=癿atch_parent", ,android: layout_marginRight=?00 dp"/祝辞, , & lt;/LinearLayout>
以上就是怎么在android中绘制多个黑竖线条,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。