android繪制多個黑豎線條
本文實(shí)例為大家分享了android繪制多個黑豎線條展示的具體代碼,供大家參考,具體內(nèi)容如下
1.寫一個LinearLayout的布局,將寬度寫成5dp將高度寫成match_parent.
2.在寫一個類繼承LinearLayout,用LayoutInflater實(shí)現(xiàn)子布局的在這個LinearLayout類中顯示。
3.直接在需要使用的xml文件中調(diào)用我們寫的這個class,注意路徑要寫全。
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>
運(yùn)行效果:

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- android圖像繪制(七)ClipRect局部繪圖/切割原圖繪制總結(jié)
- android圖像繪制(四)自定義一個SurfaceView控件
- Android開發(fā)筆記之:在ImageView上繪制圓環(huán)的實(shí)現(xiàn)方法
- android圖像繪制(二)畫布上放大縮小問題
- Android中使用ListView繪制自定義表格技巧分享
- android圖像繪制(六)獲取本地圖片或拍照圖片等圖片資源
- android圖像繪制(一)多種方法做圖像鏡像
- android圖像繪制(三)畫布刷屏問題記錄
- Android編程繪制圓形圖片的方法
- Android中使用Vectors(2)繪制優(yōu)美的路徑動畫
相關(guān)文章
Android實(shí)現(xiàn)QQ登錄界面遇到問題及解決方法
本文給大家介紹android仿qq登錄界面的實(shí)現(xiàn)代碼,在實(shí)現(xiàn)此功能過程中遇到各種問題,但是最終都順利解決,如果大家對android qq登錄界面實(shí)現(xiàn)方法感興趣的朋友一起學(xué)習(xí)吧2016-09-09
Android 兩個ViewPager的聯(lián)動效果的實(shí)現(xiàn)
這篇文章主要介紹了Android 兩個ViewPager的聯(lián)動效果的實(shí)現(xiàn),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-08-08
Android中讀取中文字符的文件與文件讀取相關(guān)介紹
InputStream.available()得到字節(jié)數(shù),然后一次讀取完,用BufferedReader.readLine()行讀取再加換行符,最后用StringBuilder.append()連接成字符串,更多祥看本文2013-06-06
基于Android XML解析與保存的實(shí)現(xiàn)
本篇文章小編為大家介紹,基于Android XML解析與保存的實(shí)現(xiàn)。需要的朋友參考下2013-04-04
完美解決android M上鎖屏情況下,禁止pc通過MTP訪問手機(jī)存儲單元
下面小編就為大家?guī)硪黄昝澜鉀Qandroid M上鎖屏情況下,禁止pc通過MTP訪問手機(jī)存儲單元。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-04-04
Android onNewIntent()觸發(fā)機(jī)制及注意事項
這篇文章主要介紹了Android onNewIntent()觸發(fā)機(jī)制及注意事項的相關(guān)資料,需要的朋友可以參考下2016-09-09
Android Http協(xié)議訪問網(wǎng)絡(luò)實(shí)例(3種)
本篇文章主要介紹了Android Http協(xié)議訪問網(wǎng)絡(luò)實(shí)例(3種),具有一定的參考價值,有興趣的可以了解一下2017-07-07

