• 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">
    
        <Button
            android:id="@+id/btn1"
            android:layout_centerInParent="true"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#999999"
            android:text="中间"
    
     />
        <Button
            android:id="@+id/btn2"
            android:layout_centerInParent="true"
            android:layout_centerHorizontal="true"
            android:layout_above="@id/btn1"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#000FF0"
            android:text="上边"
    
            />
        <Button
            android:id="@+id/btn3"
            android:layout_centerInParent="true"
            android:layout_centerHorizontal="true"
            android:layout_below="@id/btn1"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#99FF99"
            android:text="下边"
    
            />
        <Button
            android:id="@+id/btn4"
            android:layout_centerInParent="true"
            android:layout_toLeftOf="@id/btn1"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#995599"
            android:text="左边"
    
            />
        <Button
            android:id="@+id/btn5"
            android:layout_centerInParent="true"
            android:layout_toRightOf="@id/btn1"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#914449"
            android:text="右边"
    
            />
        <Button
            android:id="@+id/btn6"
            android:layout_centerInParent="true"
            android:layout_above="@id/btn1"
            android:layout_toLeftOf="@id/btn2"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#99FFF9"
            android:text="左上"
    
            />
        <Button
            android:id="@+id/btn7"
            android:layout_centerInParent="true"
            android:layout_above="@id/btn1"
            android:layout_toRightOf="@id/btn2"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#234119"
            android:text="右上"
    
            />
        <Button
            android:id="@+id/btn8"
            android:layout_centerInParent="true"
            android:layout_below="@id/btn1"
            android:layout_toRightOf="@id/btn2"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#956816"
            android:text="右下"
    
            />
        <Button
            android:id="@+id/btn9"
            android:layout_centerInParent="true"
            android:layout_below="@id/btn1"
            android:layout_toLeftOf="@id/btn2"
            android:layout_width="80dp"
            android:layout_height="80dp"
            android:background="#999999"
            android:text="左下"
    
            />
    
    
    </RelativeLayout>

     --界面

    <?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">
    
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text=""
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toTopOf="parent" />
    
        <ImageView
            android:id="@+id/p1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/timg"
            android:contentDescription="@drawable/timg"
    
            />
    
        <ImageView
            android:id="@+id/p2"
            android:layout_width="300dp"
            android:layout_height="80dp"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="100dp"
            android:background="@drawable/lv"
            android:contentDescription="@drawable/lv"
    
            />
    
        <TextView
            android:id="@+id/textView1"
            android:layout_width="match_parent"
            android:layout_below="@id/p2"
            android:layout_height="wrap_content"
            android:layout_marginTop="80dp"
            android:text="用户名:"
            android:textSize="40dp"
            android:textColor="#F8F8F8"/>
        <TextView
            android:id="@+id/textView2"
            android:layout_width="match_parent"
            android:layout_below="@id/textView1"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dp"
            android:text="密码:"
            android:textSize="40dp"
            android:textColor="#F8F8F8"/>
    
        <EditText
            android:id="@+id/EditText1"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_below="@id/p2"
            android:layout_marginTop="70dp"
            android:layout_centerHorizontal="true"
            android:hint=" 请输入用户名:"
            android:maxLines="1"
            android:textColor="#F8F8F8"
    
            android:textSize="40dp" />
    
    
        <EditText
            android:id="@+id/EditText2"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_below="@id/p2"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="134dp"
            android:hint=" 请输入密码:"
            android:maxLines="1"
            android:textColor="#F8F8F8"
            android:textSize="40dp" />
    
        <Button
            android:id="@+id/button1"
            android:layout_width="109dp"
            android:layout_height="64dp"
            android:layout_below="@id/textView2"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="132dp"
            android:background="#F8F8F8"
            android:onClick="Click"
            android:text="登录" />
    
    </RelativeLayout>
    package com.example.loadscreen;
    
    import androidx.appcompat.app.AppCompatActivity;
    
    import android.os.Bundle;
    import android.widget.Button;
    import android.view.View;
    
    public class MainActivity extends AppCompatActivity {
        private Button button1;
    
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            button1=(Button)findViewById(R.id.button1);
        } public void Click(View view){
            button1.setText("欢迎你再次使用");
        }
    }

  • 相关阅读:
    Spring Cloud Gateway 使用
    Spring Cloud Stream 整合 RabbitMQ
    机器学习知识总结---1、回归和分类是可以相互转换的
    23个适合Java开发者的大数据工具和框架
    serilog Getting Started
    NLog.Targets.ElasticSearch
    RollingFileAppender bufferSize is not working? Here is an alternative
    go微服务示例(k8s istio grpc swagger postgres增量更新sql等功能)
    undefined: grpc.SupportPackageIsVersion6 和 undefined: grpc.ClientConnInterface 解决办法
    micrometer埋点(Spring boot 2.X metrics)
  • 原文地址:https://www.cnblogs.com/tianzhiyuan/p/13707243.html
Copyright © 2020-2023  润新知