【学习笔记】Android常用布局
2016-10-22 10:52
225 查看
一、LinearLayout线性布局
(1)线性布局分为垂直和水平两个方向
//新建并设置一个RelativityLayout布局
RelativityLayout root=new RelativityLayout(this);
setContentView(root);
//添加一个textView控件
TextView tv=new TextView(this);
tv.setText("hello");
//定义RelativityLayout参数,有两个参数高和宽
RelativityLayout.LayoutParams lp=new RelativityLayout.LayoutParams(RelativityLayout.LayoutParams.WrapContent,RelativityLayout.LayoutParams.WrapContent);
root.addView(tv,lp);
三、 FrameLayout
用的比较少,加进来的控件自动堆叠在一起。日后再补充
(1)线性布局分为垂直和水平两个方向
android:orientation="vertical" android:orientation="horizontal"(2)定义宽和高
铺满父级容器:match_parent 根据内容自适应:wrap_content
android:layout_width="" android:layout_height=""(3)设置权重
android:layout_weight="1" 全部二、RelativityLayout相对布局
//新建并设置一个RelativityLayout布局
RelativityLayout root=new RelativityLayout(this);
setContentView(root);
//添加一个textView控件
TextView tv=new TextView(this);
tv.setText("hello");
//定义RelativityLayout参数,有两个参数高和宽
RelativityLayout.LayoutParams lp=new RelativityLayout.LayoutParams(RelativityLayout.LayoutParams.WrapContent,RelativityLayout.LayoutParams.WrapContent);
root.addView(tv,lp);
三、 FrameLayout
用的比较少,加进来的控件自动堆叠在一起。日后再补充
相关文章推荐
- 【Android基础笔记02】 API Guide学习和常用布局及基本UI控件
- Android用户界面设计——关于布局的学习笔记
- Android开发学习笔记-4 Activity-3 常用控件
- Android开发学习笔记(五)Android五大布局
- android22_Android的布局和Intent笔记和常用实例
- Android(OPhone) 学习笔记 - 布局
- Android的布局和Intent笔记和常用实例
- Android的布局和Intent笔记和常用实例
- Android入门学习_代码常用布局
- Android开发学习笔记:5大布局方式详解
- Android的布局和Intent笔记和常用实例
- android学习1--布局管理常用属性
- Android的布局和Intent笔记和常用实例
- Android入门学习_代码常用布局
- Android 学习笔记 (3)界面布局
- Android的布局和Intent笔记和常用实例 (转自http://blog.csdn.net/yiyaaixuexi/article/details/6337760)
- Android入门学习_代码常用布局
- android 学习笔记(五)调试相关 5.4 常用adb命令详表
- Android开发学习笔记(13):Android开发常用技术点整理(更新中...)
- Android开发入门之学习笔记(四):程序窗口的布局(二)