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>



  • 相关阅读:
    一次惨痛的debug的经历-RuntimeError: CUDA error: an illegal memory access was encountered
    Rank loss调研
    守护进程 supervisor
    PHP实现异步请求非阻塞
    PHP实现图片和文字水印(PHP给图片添加水印功能)
    虚拟机相关博客
    小师妹学JavaIO之:文件系统和WatchService
    后端 Java ActionEvent getModifiers()
    Java中常见的锁简述
    关键系统的JVM参数推荐
  • 原文地址:https://www.cnblogs.com/Toring/p/6628295.html
Copyright © 2011-2022 走看看