线性布局LinearLayout是一个视图容器,用于使所有子视图在单个方向保持对齐<?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"    tools:context=".MainActivity">    <TextView        android:layout_width="200dp"        android:layout_height="90dp"        android:background="#4593Ec"        android:gravity="center"        android:text="1"        android:textColor="@color/white"        android:textSize="25sp"/>    <TextView        android:layout_width="100dp"        android:layout_height="90dp"        android:background="#7DB145"        android:gravity="center"        android:text="2"        android:textColor="@color/white"        android:textSize="25sp"/>    <TextView        android:layout_width="80dp"        android:layout_height="90dp"        android:background="#F10000"        android:gravity="center"        android:text="3"        android:textColor="@color/white"        android:textSize="25sp"/>LinearLayout>android:orientation="vertical" 垂直方向下(图1)android:orientation="horizontal" 水平方向下(图2)


布局权重:通过给子视图设置权重值,来分配子视图所占空间的权重(比例)<?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"    tools:context=".MainActivity"    android:orientation="vertical">    <LinearLayout        android:layout_width="match_parent"        android:layout_height="100dp"        android:background="#3c3f41"/>    <View        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="2"        android:background="#ff5722"/>    <View        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_weight="1"        android:background="#4795ec"/>LinearLayout>

更多相关文章

  1. 第五章 Android(安卓)Scroll 分析
  2. Android(安卓)中文 API (36) ―― Toast
  3. Android(安卓)中文 API (102)―― CursorAdapter
  4. Android(安卓)- 信息列表页面【仿】淘宝App
  5. android一些认识
  6. android Gallery(画廊)以及BaseAdapter
  7. Android(安卓)- 小功能 - android手动开启或者关闭输入法
  8. MVP -----个人理解与示例(android例子 实现)
  9. Android(安卓)gallery详解

随机推荐

  1. Android——多语言适配
  2. Ubuntu 10.10 编译Android(安卓)2.2
  3. Android(安卓)SnackBar
  4. Android使用腾讯X5内核替换原生webview
  5. android项目中每个文件的作用
  6. android和html交互--动态注入方法
  7. Android(安卓)程序员指南 PDF下载
  8. android中usb数据通信速率慢问题解决办法
  9. Android(安卓)Studio编译release版本
  10. Android截屏实现——亲测有效代码