package com.example.myapplication;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class GridActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_grid);
}
}
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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=".GridActivity">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="3"
android:rowCount="3">
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#00a2e8"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#3f48cc"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#a349a4"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#99d9ea"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#7092be"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#c8bfe7"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#00a2e8"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#3f48cc"></TextView>
<TextView android:text="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:background="#a349a4"></TextView>
</GridLayout>
</RelativeLayout>
package com.example.myapplication;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
public class LoginActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
}
}
<?xml version="1.0" encoding="utf-8"?>
<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=".LoginActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="70dp"></TextView>
<ImageView
android:layout_width="232dp"
android:layout_height="232dp"
android:src="@mipmap/card"
android:layout_gravity="center"></ImageView>
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="用户"
android:textSize="61dp">
</TextView>
<EditText
android:layout_width="241dp"
android:layout_height="wrap_content"
android:textSize="52dp">
</EditText>
</GridLayout>
<GridLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="密码"
android:textSize="61dp">
</TextView>
<EditText
android:layout_width="241dp"
android:layout_height="wrap_content"
android:password="true"
android:textSize="52dp">
</EditText>
</GridLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>