zoukankan      html  css  js  c++  java
  • 安卓第四周作业,制作九宫格

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:paddingBottom="20dp"
        android:layout_height="match_parent">
    
        <Button
            android:id="@+id/btn1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#000000" />
        <Button
            android:id="@+id/btn2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/btn1"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#7CFC00" />
        <Button
            android:id="@+id/btn3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/btn1"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#7CFC00" />
        <Button
            android:id="@+id/btn4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/btn1"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#7CFC00" />
        <Button
            android:id="@+id/btn5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/btn1"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#7CFC00" />
        <Button
            android:id="@+id/btn6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/btn5"
            android:layout_above="@id/btn2"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#000000" />
        <Button
            android:id="@+id/btn7"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/btn5"
            android:layout_above="@id/btn2"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#000000" />
        <Button
            android:id="@+id/btn8"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toLeftOf="@id/btn1"
            android:layout_below="@id/btn3"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#000000" />
        <Button
            android:id="@+id/btn9"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/btn1"
            android:layout_below="@id/btn3"
            android:layout_centerInParent="true"
            android:width="80dp"
            android:height="80dp"
            android:background="#000000" />
    
    </RelativeLayo
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="match_parent">
    
        <ImageView
            android:id="@+id/photo"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:src="@drawable/ic_launcher_background"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="200dp"
            android:layout_marginBottom="30dp"></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="请输入您的密码"/>
        <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"
            android:layout_centerHorizontal="true">
        </Button>
    
    
    </RelativeLayout>
    package com.example.myapplication;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.annotation.SuppressLint;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.Toast;
    
    public class MainActivity extends AppCompatActivity {
    private Button btn_one;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        }
        @SuppressLint("WrongConstant")
        public void Click(View view){
            Toast.makeText(this,"你好",0).show();
        }
    
    }

  • 相关阅读:
    JVM系列【2】Class文件结构
    JVM系列【5】JVM常用指令
    JVM系列【4】内存模型
    JVM系列【3】Class文件加载过程
    新编html网页设计从入门到精通 (龙马工作室) pdf扫描版​
    HTML5移动开发即学即用(双色) 王志刚 pdf扫描版​
    HTML5和CSS3实例教程 中文版 高清PDF扫描版
    HTML5+CSS3网站设计教程 (张晓景,胡克) [iso]
    HTML5+CSS3+jQuery Mobile轻松构造APP与移动网站 (陈婉凌) 中文pdf扫描版
    HTML5 Canvas游戏开发实战 PDF扫描版
  • 原文地址:https://www.cnblogs.com/527x/p/14059487.html
Copyright © 2011-2022 走看看