Android开发一个登录界面学习总结

代码演示:

<?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”

tools:context=".MainActivity">


<RelativeLayout
    android:background="#FFFF00"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.8">

    <LinearLayout
        android:layout_marginLeft="100dp"
        android:layout_marginRight="100dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="150dp">


        <ImageView


            android:layout_width="0dp"
            android:layout_height="100dp"
            android:layout_weight="0.5"
            android:src="@drawable/icon_bic">


        </ImageView>

        <TextView
            android:id="@+id/textView"
            android:layout_width="0dp"
            android:layout_height="110dp"

            android:layout_weight="1"
            android:text="工巢"
            android:textColor="#000000"
            android:textSize="70dp"

            ></TextView>
    </LinearLayout>
</RelativeLayout>


<RelativeLayout
    android:paddingLeft="80dp"
    android:paddingRight="80dp"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="1">
    <EditText
        android:layout_marginHorizontal="40dp"
        android:layout_marginTop="40dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入账号"

        android:textColor="@android:color/black"
        />
    <ImageView
        android:layout_marginTop="36dp"
        android:layout_width="30dp"
        android:layout_height="60dp"
        android:src="@drawable/icon_phone">

    </ImageView>
    <ImageView
        android:layout_marginTop="90dp"
        android:layout_width="30dp"
        android:layout_height="60dp"
        android:src="@drawable/icon_email">

    </ImageView>

    <EditText
        android:layout_marginHorizontal="40dp"
        android:layout_marginTop="100dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="请输入验证码"


        android:textColor="@android:color/black" />

    <Button
        android:layout_marginTop="180dp"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_marginHorizontal="80dp"

        android:text="登录"

        ></Button>




</RelativeLayout>

1:主要用的是LinearLayout布局,学习到可以使用RelativeLayout相对布局,先用相对布局分割为两部分
2:把需要使用的图片添加到资源文件夹中在这里插入图片描述
3:第一部分设立背景颜色,在添加图片和文本在这里插入图片描述

4:添加第二部分的图片和文本,还有登录按钮,这个颜色不是普通黄色,是用Color Cop 抓取来的)在这里插入图片描述

运行结果
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44941105/article/details/114881799