Skip to content

Mikuyu19/Android-1

Repository files navigation

Android课后作业1

完成课本36页:制作一个登录与注册界面

源文件代码已上传至GitHub

地址:https://github.com/Mikuyu19/Android-1

完成示例图:

test.jpg

制作相关代码

主界面Layout_main

 

<?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:padding="10dp"
    android:background="@drawable/c"
    tools:context=".MainActivity">
&lt;ImageView
    android:id=&quot;@+id/android_icon&quot;
    android:layout_width=&quot;96dp&quot;
    android:layout_height=&quot;96dp&quot;
    android:layout_gravity=&quot;center&quot;
    android:layout_marginTop=&quot;150dp&quot;
    android:src=&quot;@drawable/android_icon&quot; /&gt;

&lt;EditText
    android:id=&quot;@+id/et_username&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;50dp&quot;
    android:layout_marginTop=&quot;50dp&quot;
    android:background=&quot;@drawable/bg_username&quot;
    android:drawableStart=&quot;@drawable/ic_username&quot;
    android:drawablePadding=&quot;8dp&quot;
    android:hint=&quot;用户名&quot;
    android:textColor=&quot;@color/white&quot;
    android:inputType=&quot;text&quot;
    android:padding=&quot;10dp&quot;
    android:textSize=&quot;16sp&quot; /&gt;

&lt;EditText
    android:id=&quot;@+id/et_password&quot;
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;50dp&quot;
    android:drawableStart=&quot;@drawable/ic_password&quot;
    android:drawablePadding=&quot;8dp&quot;
    android:layout_marginTop=&quot;5dp&quot;
    android:background=&quot;@drawable/bg_username&quot;
    android:hint=&quot;密码&quot;
    android:textColor=&quot;@color/white&quot;
    android:inputType=&quot;textPassword&quot;
    android:padding=&quot;10dp&quot;
    android:textSize=&quot;16sp&quot;
    /&gt;
&lt;LinearLayout
    android:layout_width=&quot;match_parent&quot;
    android:layout_height=&quot;wrap_content&quot;
    android:layout_marginTop=&quot;20dp&quot;
    android:orientation=&quot;horizontal&quot;&gt;

    &lt;Button
        android:id=&quot;@+id/btn_login&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;50dp&quot;
        android:layout_gravity=&quot;center&quot;
        android:gravity=&quot;center&quot;
        android:layout_weight=&quot;1&quot;
        android:background=&quot;@drawable/btn_left&quot;
        android:text=&quot;登录&quot;
        android:textColor=&quot;@color/white&quot;
        android:textSize=&quot;16sp&quot;/&gt;

    &lt;Button
        android:id=&quot;@+id/btn_register&quot;
        android:layout_width=&quot;0dp&quot;
        android:layout_height=&quot;50dp&quot;
        android:layout_gravity=&quot;center&quot;
        android:layout_marginLeft=&quot;5dp&quot;
        android:layout_weight=&quot;1&quot;
        android:background=&quot;@drawable/btn_right&quot;
        android:gravity=&quot;center&quot;
        android:text=&quot;注册&quot;
        android:textColor=&quot;@color/white&quot;
        android:textSize=&quot;16sp&quot; /&gt;

&lt;/LinearLayout&gt;

</LinearLayout>

 

MainActivity.java

package com.example.class_test;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle; import android.view.View;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

}

其他布局文件请查看源代码

About

这里记录Android课程的源文件代码

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages