文末有代碼和圖片
知識(shí)點(diǎn)1:
五大布局:
FrameLayout 幀布局
LinearLayout 線性布局
RelativeLayout 相對(duì)布局
TableLayout 表格布局
ConstraintLayout 約束布局
1庸疾、在drawable文件夾中添加圖片(注:以小寫字母開頭)
添加圖片
2捡多、修改相關(guān)代碼
①修改為線性布局
②設(shè)置線性布局為垂直布局
③設(shè)置背景圖片
④設(shè)置ImageView的背景圖片
⑤設(shè)置嵌套線性布局,為水平布局(登錄與注冊(cè)在同一水平)
修改代碼
3、模擬機(jī)顯示效果:
模擬機(jī)顯示效果
代碼如下:
<?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="賬號(hào):"
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="注冊(cè)"
android:layout_marginLeft="5dp"/>
</LinearLayout>
</LinearLayout>
android.png
bg.png