LinearLayout:线性布局的控件,要么横向排布要么纵向排布
无论是哪种排布,都由android:orientation来控制,其中vertical是横向,Horizaontal是纵向
常用的属性:
android:gravity————设置的是控件自身上面的内容位置

android:layout_gravity—–设置控件本身相对于父控件的显示位置

android:layout_weight—– 给控件分配剩余空间

代码举例:"http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"//宽度填满整个空间    android:layout_height="match_parent"空间//高度填满    android:baselineAligned="false"    android:orientation="vertical">//横向排布    

顺便清楚一下其中的fill_parent,wrap_content和match_parent之间的区别
1)fill_parent是设置一个顶部布局或控件强制性让它布满整个屏幕
2)wrap_content布局指根据视图内部内容自动扩展以适应其大小。
3)match_parent和fill_parent的用法一样

代码举例:wrap_content:<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:app="http://schemas.android.com/apk/res-auto"    xmlns:tools="http://schemas.android.com/tools"    android:id="@+id/activity_main"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:baselineAligned="false"    android:orientation="vertical">    <Botton    android:id="@+id/btnButton1"    android:layout_width="wrap_content"    android:layout_height="wrap_content"    android:text="Button CJP"/> RelativeLayout>

初学Android学到的关于LinearLayout的知识_第1张图片

更多相关文章

  1. Android中 GridLayout 【网格布局】 全面解析
  2. 布局指令大全
  3. Android控件布局常用属性
  4. Android 线性布局
  5. Android动态生成控件居中显示
  6. Android--动态添加控件
  7. android > TimePicker 时间设置控件
  8. Android Layout 布局属性全解

随机推荐

  1. android的文件操作
  2. Android(安卓)2.1 源码结构分析
  3. Android开发常用网站
  4. Android资源汇总---持续整理更新中!!!
  5. android : 圆角按钮 shape属性
  6. android获取手机中的短信和,android获取
  7. AndroidMenifest.xml中minSdkVersion、ta
  8. 【Android(安卓)ndk-stack tool】用ndk-s
  9. Android编译过程详解(三)
  10. 丰富多彩的Android(安卓)onTouch事件