zoukankan      html  css  js  c++  java
  • Android布局(1)--线性布局(LinerLayout)

    Android应用程序的界面由布局管理器类和ViewGroup类创建。

    线性布局是所有布局中最简单的布局,它将放入其中的组件按照垂直或水平方向进行排列。在线性布局中每一行或者每一列只能有一个组件,并且这些组件不会换行。当组件一个一个排列到父窗口的边缘时候,会自动隐藏剩下的组件。


    垂直排列:

    <?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="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:gravity="top|center"
        android:background="#0000FF"
        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.example.demo.LinearLayout">
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/button1"
            android:text="进入系统"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/button2"
            android:text="网络配置"/>
        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:id="@+id/button3"
            android:text="退出系统"/>
    
    </LinearLayout>

    水平排列:

    <?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="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        android:gravity="top|center"
        android:background="#0000FF"
        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.example.demo.LinearLayout">
        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/button1"
            android:text="进入系统"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/button2"
            android:text="网络配置"/>
        <Button
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:id="@+id/button3"
            android:text="退出系统"/>
    
    </LinearLayout>



  • 相关阅读:
    Android 懒加载简单介绍
    Android 使用RxJava实现一个发布/订阅事件总线
    Android 第三方库RxLifecycle使用
    Android 使用Retrofit2.0+OkHttp3.0实现缓存处理+Cookie持久化第三方库
    代码雨
    我的第一个博客(My first blog)
    merge法
    如何使用git将remote master上的内容merge 到自己的开发分支上  &  以及将自己分支的内容merge到remote master上...
    git 解决冲突
    Mac安装和破解激活Charles
  • 原文地址:https://www.cnblogs.com/Toring/p/6628295.html
Copyright © 2011-2022 走看看