Android第四周作业

九宫格

<?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=".MainActivity"
    android:orientation="vertical">

    <Button
        android:id="@+id/one"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#00868B"
        android:layout_centerInParent="true" />

    <Button
        android:id="@+id/two"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#2E8B57"
        android:layout_alignBottom="@+id/one"
        android:layout_toLeftOf="@+id/one"/>

    <Button
        android:id="@+id/three"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#6495ED"
        android:layout_alignBottom="@+id/one"
        android:layout_toRightOf="@+id/one"/>/>

    <Button
        android:id="@+id/four"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#EEAD0E"
        android:layout_alignLeft="@+id/one"
        android:layout_above="@+id/one"/>

    <Button
        android:id="@+id/five"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#8B658B"
        android:layout_alignLeft="@+id/one"
        android:layout_below="@+id/one"/>/>

    <Button
        android:id="@+id/six"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#FF6A6A"
        android:layout_alignLeft="@+id/two"
        android:layout_above="@+id/one"/>/>

    <Button
        android:id="@+id/seven"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#8B4513"
        android:layout_alignLeft="@+id/two"
        android:layout_below="@+id/one"/>/>

    <Button
        android:id="@+id/eight"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#FF69B4"
        android:layout_alignLeft="@+id/three"
        android:layout_above="@+id/one"/>/>

    <Button
        android:id="@+id/nine"
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="#8B8682"
        android:layout_alignLeft="@+id/three"
        android:layout_below="@+id/one"/>/>

</RelativeLayout>

 登录点击界面

<?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:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@mipmap/ic_launcher"
    android:layout_marginTop="150dp"
    android:layout_centerHorizontal="true"/>

<EditText
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:text="请输入用户名:"
    android:layout_marginTop="250dp"
    android:layout_centerHorizontal="true"/>

<EditText
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:text="请输入用户名:"
    android:layout_marginTop="300dp"
    android:layout_centerHorizontal="true"/>
<Button
    android:layout_width="100dp"
    android:layout_height="50dp"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="350dp"
    android:text="登录"
    android:onClick="click"/>
</RelativeLayout>

原文地址:https://www.cnblogs.com/student-yyh/p/13697538.html