安卓第四周作业

<?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=".MainActivity">
 
 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="match_parent"
        android:paddingTop="200dp" android:paddingLeft="20dp">
 
        <Button
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:id="@+id/btn1"
        android:text="111"
        android:background="#528654">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn2"
            android:text="222"
            android:layout_toRightOf="@id/btn1"
            android:background="#896899">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn3"
            android:text="333"
            android:layout_toRightOf="@id/btn2"
            android:background="#212360">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn4"
            android:text="444"
            android:layout_below="@id/btn1"
            android:background="#FF2589">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn5"
            android:text="555"
            android:layout_below="@id/btn1"
            android:layout_toRightOf="@id/btn4"
            android:background="#008854">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn6"
            android:text="666"
            android:layout_below="@id/btn1"
            android:layout_toRightOf="@id/btn5"
            android:background="#788877">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn7"
            android:text="777"
            android:layout_below="@id/btn4"
            android:background="#896888">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn8"
            android:text="888"
            android:layout_below="@id/btn4"
            android:layout_toRightOf="@id/btn7"
            android:background="#DD4588">
        </Button>
 
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn9"
            android:text="999"
            android:layout_below="@id/btn4"
            android:layout_toRightOf="@id/btn8"
            android:background="#AA2548">
        </Button>
    </RelativeLayout>
 
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 
    <ImageView
        android:id="@+id/photo"
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:layout_centerInParent="true"
        android:src="@drawable/photo"></ImageView>
 
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/photo"
        android:maxLength="15"
        android:layout_marginTop="13dp"
        android:text="账号:"/>
 
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/photo"
        android:layout_toRightOf="@id/textView1"
        android:hint="请输入您的账号"></EditText>
 
 
    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/textView1"
        android:maxLength="20"
        android:layout_marginTop="25dp"
        android:text="密码:" />
 
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/textView1"
        android:layout_toRightOf="@id/textView2"
        android:layout_marginTop="10dp"
        android:hint="请输入您的密码">
    </EditText>
 
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/button"
        android:text="登录"
        android:textColor="#478595"
        android:layout_below="@id/textView2"
        android:layout_marginTop="20dp"
        android:layout_marginLeft="120dp"
        android:onClick="click">
    </Button>
 
</RelativeLayout>
package com.example.myhomework1;
 
import androidx.appcompat.app.AppCompatActivity;
 
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
 
public class MainActivity extends AppCompatActivity {
 
    private Button mybutton_one;
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        mybutton_one = (Button) findViewById(R.id.button);
    }
 
 
    public void click(View view){
        mybutton_one.setText("登录按钮被点击");
    }
}

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?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=".MainActivity">
  
  
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent" android:layout_height="match_parent"
        android:paddingTop="200dp" android:paddingLeft="20dp">
  
        <Button
        android:layout_width="80dp"
        android:layout_height="80dp"
        android:id="@+id/btn1"
        android:text="111"
        android:background="#528654">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn2"
            android:text="222"
            android:layout_toRightOf="@id/btn1"
            android:background="#896899">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn3"
            android:text="333"
            android:layout_toRightOf="@id/btn2"
            android:background="#212360">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn4"
            android:text="444"
            android:layout_below="@id/btn1"
            android:background="#FF2589">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn5"
            android:text="555"
            android:layout_below="@id/btn1"
            android:layout_toRightOf="@id/btn4"
            android:background="#008854">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn6"
            android:text="666"
            android:layout_below="@id/btn1"
            android:layout_toRightOf="@id/btn5"
            android:background="#788877">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn7"
            android:text="777"
            android:layout_below="@id/btn4"
            android:background="#896888">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn8"
            android:text="888"
            android:layout_below="@id/btn4"
            android:layout_toRightOf="@id/btn7"
            android:background="#DD4588">
        </Button>
  
        <Button
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:id="@+id/btn9"
            android:text="999"
            android:layout_below="@id/btn4"
            android:layout_toRightOf="@id/btn8"
            android:background="#AA2548">
        </Button>
    </RelativeLayout>
  
</androidx.constraintlayout.widget.ConstraintLayout>

  

posted @ 2020-09-22 16:01  计算机小Inati  阅读(63)  评论(0编辑  收藏  举报