本篇文章給大家分享的是有關(guān)怎么在android中繪制多個(gè)黑豎線(xiàn)條,小編覺(jué)得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話(huà)不多說(shuō),跟著小編一起來(lái)看看吧。
成都創(chuàng)新互聯(lián)公司專(zhuān)注骨干網(wǎng)絡(luò)服務(wù)器租用10余年,服務(wù)更有保障!服務(wù)器租用,雅安移動(dòng)機(jī)房 成都服務(wù)器租用,成都服務(wù)器托管,骨干網(wǎng)絡(luò)帶寬,享受低延遲,高速訪(fǎng)問(wèn)。靈活、實(shí)現(xiàn)低成本的共享或公網(wǎng)數(shù)據(jù)中心高速帶寬的專(zhuān)屬高性能服務(wù)器。
1.寫(xiě)一個(gè)LinearLayout的布局,將寬度寫(xiě)成5dp將高度寫(xiě)成match_parent.
2.在寫(xiě)一個(gè)類(lèi)繼承LinearLayout,用LayoutInflater實(shí)現(xiàn)子布局的在這個(gè)LinearLayout類(lèi)中顯示。
3.直接在需要使用的xml文件中調(diào)用我們寫(xiě)的這個(gè)class,注意路徑要寫(xiě)全。
1.xml代碼
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="5dp" android:layout_height="match_parent" android:background="#000000" > </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 on 2018/5/7. */ public class Linedemo extends LinearLayout { public Linedemo(Context context, @Nullable AttributeSet attrs) { super(context, attrs); LayoutInflater.from(context).inflate(R.layout.line,this); } }
3.布局代碼
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="10dp" > <com.example.lenovo.myfragmentdemo3.Linedemo android:layout_width="20dp" android:layout_height="match_parent" android:layout_marginRight="100dp"/> <com.example.lenovo.myfragmentdemo3.Linedemo android:layout_width="20dp" android:layout_height="match_parent" android:layout_marginRight="100dp"/> <com.example.lenovo.myfragmentdemo3.Linedemo android:layout_width="20dp" android:layout_height="match_parent" android:layout_marginRight="100dp"/> <com.example.lenovo.myfragmentdemo3.Linedemo android:layout_width="20dp" android:layout_height="match_parent" android:layout_marginRight="100dp"/> </LinearLayout>
以上就是怎么在android中繪制多個(gè)黑豎線(xiàn)條,小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見(jiàn)到或用到的。希望你能通過(guò)這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁(yè)名稱(chēng):怎么在android中繪制多個(gè)黑豎線(xiàn)條
當(dāng)前鏈接:http://aaarwkj.com/article32/ijpcsc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、網(wǎng)站排名、微信公眾號(hào)、搜索引擎優(yōu)化、云服務(wù)器、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)