Inventory before the Android final exam (3): learn a layout scheme to deal with the final (Part 2)

Since there are many animations in the article for better demonstration, the article storage is limited and divided into several articles

Then I need to set the properties of the control, which can be modified in the code or changed in the properties on the right: For example, I modify text and other properties as follows

Let me quickly demonstrate how to make a simple login interface

The second is the LinearLayout layout, which can deal with 95% of the interface layout situations at the end of the period. It is suitable for novices, and the amount of code is not much, and the implementation effect is good.

First of all, we must understand that the layout arrangement includes horizontal (horizontal) and vertical (vertical), such as the picture below, and it is obvious that 5 controls are used in the picture, all of which are arranged vertically (vertically), so we only need to use LinearLayout set up

orientation="vertical"

Then this is also one of the most important attributes of LinearLayout, and the lack of this attribute layout will also report an error

What about horizontal (landscape) alignment?

android:orientation="horizontal"

 So for example, the previous simple login using ConstraintLayout layout, I can use LinearLayout to write: the code is as follows:

<?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=".MainActivity70">

    <ImageView
        android:id="@+id/imageView6"
        android:layout_width="187dp"
        android:layout_height="187dp"
        android:layout_marginStart="99dp"
        android:layout_marginTop="56dp"

        app:srcCompat="@drawable/a111" />

    <EditText
        android:id="@+id/editTextTextPassword3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginStart="100dp"
        android:ems="10"
        android:inputType="textPassword" />

    <EditText
        android:id="@+id/editTextTextEmailAddress2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="10"
        android:layout_marginStart="100dp"
        android:inputType="textEmailAddress" />

    <Button
        android:id="@+id/button14"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="登录"
        android:layout_marginStart="100dp" />

    <Button
        android:id="@+id/button15"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="注册"
        android:layout_marginStart="100dp" />
</LinearLayout>

Guess you like

Origin blog.csdn.net/m0_59558544/article/details/131200633