美文网首页
18.9.11-线性布局

18.9.11-线性布局

作者: VGSemir | 来源:发表于2018-09-11 18:40 被阅读0次

线性布局

常用属性

  1. id: 相当于标识符
  2. background
  3. padding: 内边距 margin: 外边距
  4. gravity: 设置相对位置
  5. orientation: 排列方向

Demo:

<?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"
    android:orientation="vertical"
    tools:context=".MainActivity">

    <!--
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />
     -->

    <LinearLayout
        android:id="@+id/ll_1"
        android:layout_width="200dp"
        android:layout_height="200dp"
        android:background="#109890"
        android:orientation="vertical"
        android:padding="20dp">
        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#FF0033" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="200dp"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp"
        android:layout_marginTop="20dp"
        android:background="#0997F7"
        android:orientation="horizontal">

        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#808080"
            android:layout_weight="1"/>
        <View
            android:layout_width="0dp"
            android:layout_height="match_parent"
            android:background="#CC33CC"
            android:layout_weight="1"/>

    </LinearLayout>
    
</LinearLayout>

相关文章

  • 18.9.11-线性布局

    线性布局 常用属性 id: 相当于标识符 background padding: 内边距 margin: 外边...

  • 18.9.11-相对布局

    相对布局 常用属性 toLeftOf: 置于左侧 alignBottom: 底部对齐 alignParentBot...

  • 安卓原生页面布局总结

    布局分为线性布局:LinearLayout和相对布局:RelativeLayout 线性布局:LinearLayo...

  • Android之布局

    LinearLayout - 线性布局 线性布局,最常用的布局之一,所有包含在线性布局里的控件在线性方向上依次排列...

  • Android应用界面开发——第二周笔记

    线性布局 线性布局是程序中常见的布局方式之一,包括水平线性布局和垂直线性布局两种, 通过Android:orien...

  • 常用的五大布局

    常用的五大布局(线性布局,相对布局,帧布局,表格布局,绝对布局) 1,线性布局 LinearLayout ...

  • 3.1 布局类Widget-线性布局Row和Column

    线性布局Row和Column弹性布局Felx 线性布局Row和Column 所谓线性布局,即指沿水平或垂直方向排布...

  • 四大layout

    LinerLayout 线性布局 LinerLayout, 中文名为线性布局。这个布局会将它所包含的控件在线性方向...

  • 布局 - 线性布局

    LinearLayout 线性布局 线性布局是一种非常常用的布局,控件在该布局中按线性方向依次排列。 属性 and...

  • 2019-03-15

    实验内容:关于线性布局、约束布局及表格布局的使用 主要代码: 主界面: 线性布局: 约束布局: 表格布局: 截图:...

网友评论

      本文标题:18.9.11-线性布局

      本文链接:https://www.haomeiwen.com/subject/zozugftx.html