This series of IoT App development notes are the learning notes of station B video tutorials, video address:

  • Day1 How does Android project code work
  • Day2 Common controls and interface layout design (part 1)
  • Day3 Common controls and interface layout design (part 2)
  • Day4 Import of MQTT Jar package and debugging of Internet of Things
  • Day5 APP practical control of Internet of Things ESP8266
  • 【7 days Java0 basic Crash Android development 】
  • [7-day Java0 Basic Rapid Android Development] Day7 achievement Demonstration

1. LinearLayout

Implement the layout code:


      
<androidx.constraintlayout.widget.ConstraintLayout 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"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="200dp"
            android:layout_margin="10dp"
            android:src="@drawable/pic_001"
            />
        </LinearLayout>// First column information<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">//1x1 information temperature<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:src="@drawable/temp">

            </ImageView>
                <TextView
                    android:id="@+id/temp_textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="25sp"
                    android:text="25.2 ℃">
                </TextView>

            </LinearLayout>/ / 1 x2 humidity<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical"
                android:layout_weight="1"
                android:layout_gravity="center">
                <ImageView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:src="@drawable/humi"
                    android:layout_gravity="center"
                    />
                <TextView
                    android:id="@+id/humi_textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="25sp"
                    android:text="33 %RPH">
                </TextView>
            </LinearLayout>

        </LinearLayout>
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text=""
            android:textSize="20sp"
            />// Second column information<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">//2x1 information brightness<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:src="@drawable/lightness">

                </ImageView>
                <TextView
                    android:id="@+id/lightness_textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="25sp"
                    android:text="123 Lux">
                </TextView>

            </LinearLayout>//2x2 information gas<LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:orientation="vertical">
                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:src="@drawable/gas">

                </ImageView>
                <TextView
                    android:id="@+id/gas_textview"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:gravity="center"
                    android:textSize="25sp"
                    android:text="5%">
                </TextView>

            </LinearLayout>

        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text=""
            android:textSize="20sp"
            />// Display timer information<LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Current timing time :"
            android:textSize="15sp"
            android:gravity="center"
            android:layout_weight="1"
            />
            <TextView
                android:id="@+id/time_textview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="The 2020-03-07 17:40:00"
                android:textSize="15sp"
                android:gravity="center"
                android:layout_weight="1"
                />
            
        </LinearLayout>

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text=""
            android:textSize="20sp"
            />// Bottom timer button<Button
            android:id="@+id/button_timer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:text="Timing"
            />// Bottom timer button<Button
            android:id="@+id/button_exit"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="20sp"
            android:text="Log out"
            />

    </LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
Copy the code

2. RelativeLayout

To write…

3. FameLayout (Frame Layout)

To write…

4. Percentage layout

To write…

Welcome to subscribe to my wechat official account: “McUlover666”.