在content_main.xml中可以这样写:
<?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:layout_width="match_parent"    android:layout_height="match_parent"    app:layout_behavior="@string/appbar_scrolling_view_behavior"    tools:context="com.example.a1.myfirstp.MainActivity"    tools:showIn="@layout/activity_main"    android:orientation="vertical"    >LinearLayout>
android:layout_width="match_parent"   表示宽的属性为match_parent(匹配父控件),还可以设置为wrap_content(包含内容)

android:layout_height="match_parent" 高的属性

android:orientation="vertical"    orientation表示排列方式,vertical表示垂直排列,也可以用horizontal水平排列
可以嵌套线性布局:

线性布局中的控件可以使用android:layout_weight属性,表示将父控件的剩余空间按比例分配;

如第一个控件的weight值为1,第二个为1;表示将父控件的剩余空间按1:1分配(不包括控件text内容的大小)

第一个值为2,第二个值为1,表示按2:1分配,以此类推;

   


更多相关文章

  1. android xml布局文件属性说明
  2. ListView 常用属性 详解
  3. Android界面布局开发使用的标签介绍
  4. android timed gpio (linux 3.0.0) 受时钟控制的gpio
  5. Android控件之EditText(输入文本框控件)
  6. Android(安卓)布局
  7. Android(安卓)自定义View之手势解锁控件
  8. android > 控件 > RadioGroup
  9. Android(安卓)Studio 基础控件使用

随机推荐

  1. android 中文 api (72) ―― BluetoothSock
  2. Activity伪造Dialog的时候不能全屏显示
  3. Android(安卓)Do not keep activities选
  4. Android端与服务端基于TCP/IP协议的Socke
  5. 基于Cortex-A8的fs_s5pc100开发平台研发
  6. Android(安卓)NDK 开发教程四:TwoLibs示例
  7. Android(安卓)查看Android源码版本
  8. Android(安卓)5.0学习之定义阴影
  9. Android之Bitmap 高效加载
  10. android BaseAdapter中改变某个item的部