日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當前位置:首頁 > 芯聞號 > 充電吧
[導讀]1、LinearLayout可以在控件中使用:android:layout_weight="1" android:layout_width="0dp"設置控件占屏幕寬度,上表示占屏幕1/2。2、Tab

1、LinearLayout

可以在控件中使用:


android:layout_weight="1"
android:layout_width="0dp"

設置控件占屏幕寬度,上表示占屏幕1/2。


2、TableLayout



上指定為1表示拉伸第2列,指定為0表示拉伸第1列




指定控件所占列數(shù),上表示占兩列的空間。


3、創(chuàng)建自定義控件 XML、java、include標簽

java:

加載布局后


LayoutInflater.from(context).inflate(R.layout.title,?this);


優(yōu):可以在代碼中設置點擊事件


package?com.example.comeonlinearlayouttitle;

import?android.content.Context;
import?android.util.AttributeSet;
import?android.view.LayoutInflater;
import?android.widget.LinearLayout;
import?android.widget.Button;
import?android.view.View;
import?android.annotation.SuppressLint;
import?android.app.Activity;
@SuppressLint("NewApi")
public?class?TitleLayout?extends?LinearLayout{

	public?TitleLayout(Context?context)?{
		super(context);
		//?TODO?Auto-generated?constructor?stub
	}
	public?TitleLayout(Context?context,?AttributeSet?attrs)?{
		super(context,?attrs);
		//?TODO?Auto-generated?constructor?stub
		LayoutInflater.from(context).inflate(R.layout.title,?this);
		
		Button?back_btn?=?(Button)findViewById(R.id.back);
		back_btn.setOnClickListener(new?OnClickListener(){
			@Override
			public?void?onClick(View?view){
				//Context?android.view.View.getContext()
				//Returns?the?context?the?view?is?running?in
				((Activity)?getContext()).finish();
			}
		});
	}
	public?TitleLayout(Context?context,?AttributeSet?attrs,?int?defStyle)?{
		super(context,?attrs,?defStyle);
		//?TODO?Auto-generated?constructor?stub
	}

	

	

}

在XML中使用



-->

在XML中寫,使用include標簽





完整代碼在:https://github.com/HiSunny/ComeOnTitle.git

本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關閉