zoukankan      html  css  js  c++  java
  • 安卓学习之二--布局

     

    1.线性布局

    <?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"
        android:gravity="center"
        tools:context=".MainActivity">
    
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">
    
            <TextView
                android:id="@+id/textView6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
    android:textSize="20dp"
                android:text="用户名" />
    
            <EditText
                android:id="@+id/editText9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:layout_marginLeft="10dp"
                android:hint="请输入用户名"
                android:inputType="textPersonName" />
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">
    
            <TextView
                android:id="@+id/textView7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textSize="20dp"
    
                android:text="密码" />
    
            <EditText
                android:id="@+id/editText11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:ems="10"
                android:layout_marginLeft="10dp"
                android:hint="请输入密码"
                android:inputType="textPassword" />
    
        </LinearLayout>
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:orientation="horizontal">
    
            <Button
                android:id="@+id/button5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="登录" />
    
            <Button
                android:id="@+id/button6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="注册" />
        </LinearLayout>
    </LinearLayout>

     2.表格布局

     

    <?xml version="1.0" encoding="utf-8"?>
    <TableLayout 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"
        android:gravity="center"
        android:background="@mipmap/background"
        tools:context=".MainActivity">
    
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="vertical">
    
                <TextView
                    android:id="@+id/textView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="2018年12月25日" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="horizontal">
    
                <ImageView
                    android:id="@+id/imageView"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_02" />
    
                <ImageView
                    android:id="@+id/imageView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_10" />
    
                <ImageView
                    android:id="@+id/imageView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_04" />
            </LinearLayout>
        </TableRow>
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1" >
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="horizontal">
    
                <ImageView
                    android:id="@+id/imageView6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_16" />
    
                <ImageView
                    android:id="@+id/imageView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_19" />
    
                <ImageView
                    android:id="@+id/imageView5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_14" />
            </LinearLayout>
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:gravity="center"
                android:orientation="horizontal">
    
                <ImageView
                    android:id="@+id/imageView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:src="@mipmap/little_animal_10" />
    
                <TextView
                    android:id="@+id/textView10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="2"
                    android:text="转到音乐" />
            </LinearLayout>
        </TableRow>
    
        <TableRow
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1"
            android:gravity="left">
    
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:gravity="left|center_vertical"
                android:orientation="horizontal">
    
                <ImageView
                    android:id="@+id/imageView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:layout_marginLeft="30dp"
                    android:src="@mipmap/little_animal_06" />
    
                <TextView
                    android:id="@+id/textView11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:text="电子邮件" />
            </LinearLayout>
        </TableRow>
    </TableLayout>

     3.约束布局

    <?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"
        android:gravity="center"
        android:background="@mipmap/background"
        tools:context=".MainActivity">
    
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="2"
            android:orientation="horizontal">
    
        </LinearLayout>
    
        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_weight="1">
    
            <ImageView
                android:id="@+id/imageView12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:src="@mipmap/little_animal_14"
                app:layout_constraintBottom_toBottomOf="@+id/imageView9"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.125"
                app:layout_constraintStart_toEndOf="@+id/imageView9"
                app:layout_constraintTop_toTopOf="@+id/imageView9"
                app:layout_constraintVertical_bias="0.0" />
    
            <ImageView
                android:id="@+id/imageView11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginBottom="8dp"
                android:src="@mipmap/little_animal_10"
                app:layout_constraintBottom_toTopOf="@+id/imageView9"
                app:layout_constraintEnd_toEndOf="@+id/imageView9"
                app:layout_constraintStart_toStartOf="@+id/imageView9"
                app:layout_constraintTop_toTopOf="parent" />
    
            <ImageView
                android:id="@+id/imageView9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginBottom="8dp"
                android:src="@mipmap/little_animal_04"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />
    
            <ImageView
                android:id="@+id/imageView10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="8dp"
                android:layout_marginLeft="8dp"
                android:layout_marginEnd="8dp"
                android:layout_marginRight="8dp"
                android:layout_marginBottom="8dp"
                android:src="@mipmap/little_animal_06"
                app:layout_constraintBottom_toBottomOf="@+id/imageView9"
                app:layout_constraintEnd_toStartOf="@+id/imageView9"
                app:layout_constraintHorizontal_bias="0.861"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="@+id/imageView9" />
    
            <ImageView
                android:id="@+id/imageView13"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="8dp"
                android:src="@mipmap/little_animal_19"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="@+id/imageView9"
                app:layout_constraintStart_toStartOf="@+id/imageView9"
                app:layout_constraintTop_toBottomOf="@+id/imageView9" />
        </android.support.constraint.ConstraintLayout>
    </LinearLayout>
  • 相关阅读:
    appium连接夜游神的方法
    selenium自动化测试配置工具整理
    appium+Python 启动app(三)登录
    appium+Python 启动app(二)
    appium+Python 启动app(一)
    appium滑动操作(向上、向下、向左、向右)
    【Prometheus专题】4. Prometheus通过webhook集成Slack或Mattermost发送告警
    【Prometheus专题】3. Prometheus监控组件的配置
    【Prometheus专题】2. Prometheus监控组件安装
    【Prometheus专题】1. Prometheus介绍(何为Prometheus)
  • 原文地址:https://www.cnblogs.com/xinzhyu/p/10171739.html
Copyright © 2011-2022 走看看