Android Studio做登錄界面

文末有代碼和圖片


知識點1:
五大布局:
FrameLayout 幀布局
LinearLayout 線性布局
RelativeLayout 相對布局
TableLayout 表格布局
ConstraintLayout 約束布局


1、在drawable文件夾中添加圖片(注:以小寫字母開頭)

添加圖片

2、修改相關(guān)代碼

①修改為線性布局
②設(shè)置線性布局為垂直布局
③設(shè)置背景圖片
④設(shè)置ImageView的背景圖片
⑤設(shè)置嵌套線性布局,為水平布局(登錄與注冊在同一水平)


修改代碼

3、模擬機顯示效果:

模擬機顯示效果

代碼如下:

<?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:background="@drawable/bg"
    tools:context=".MainActivity">

    <ImageView
        android:layout_width="100dp"
        android:layout_height="100dp"
        android:background="@drawable/android"
        android:layout_marginTop="200dp"
        android:layout_gravity="center"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="賬號:"
        android:layout_marginTop="30dp"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"/>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="密碼:"
        android:layout_marginTop="10dp"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp"/>
    <CheckBox
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="記住密碼"
        android:layout_marginLeft="280dp"/>

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:layout_marginTop="10dp">

        <Button
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:text="登錄"
            android:layout_marginLeft="50dp"/>
        <Button
            android:layout_width="150dp"
            android:layout_height="wrap_content"
            android:text="注冊"
            android:layout_marginLeft="5dp"/>

    </LinearLayout>

</LinearLayout>
android.png

bg.png
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容