zoukankan      html  css  js  c++  java
  • 2.1线性布局

    线性布局:

    方向(android:orientation):多个线性布局相对父布局的位置方向

    布局对齐(android:layout_gravity):单个布局相对父布局的位置

    内容布局(android:gravity):内容相对布局的位置

    权重(android:layout_weight):占的空间比重 权重越大占用空间越大

    对齐方式(属性字段):比如 top:center_horizontal 水平居中 顶部对齐

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="com.liang.layoutdemo.MainActivity">
        <!--android:orientation 布局方向-->
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:background="#cccccc"
                android:gravity="right">
                <!--android:gravity 内容对齐-->
                <Button
                    android:id="@+id/btnlogin"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="登录" />
            </LinearLayout>
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:background="#ffaacc">
                <!--android:layout_gravity 布局对齐-->
                <Button
                    android:id="@+id/btn1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="one" />
                <!--android:layout_weight 权重 权重越大占用空间越大-->
                <Button
                    android:id="@+id/btn2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="5"
                    android:text="two" />
                <Button
                    android:id="@+id/btn3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="3"
                    android:text="three" />
            </LinearLayout>
        </LinearLayout>
    
    </LinearLayout>
  • 相关阅读:
    js中点击空白区域时文本框与隐藏层的问题
    嗨翻C语言
    人工模拟获取latch
    如何JOPtionPane的showConfirmDialog对话框button设置监视器
    本机Ajax异步通信
    Project Euler:Problem 28 Number spiral diagonals
    Maven软件项目管理工具
    第一个打击木马病毒查杀007一片:反向熊猫的分析(下一个)
    Redefine:Change in the Changing World
    不一致的文件编码读取和写入文件乱码解决方案
  • 原文地址:https://www.cnblogs.com/manusas/p/5519583.html
Copyright © 2011-2022 走看看