หลังจากเปิดโปรเจ็ค android studio ก็ทำตามด้านล่างเลยค่ะ
แก้ไขที่ไฟล์ / activity_main.xml
เปลี่ยน androidx.constraintlayout.widget.ConstraintLayout เป็น RelativeLayout
โค้ด: เลือกทั้งหมด
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayoutxmlns: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">
</androidx.constraintlayout.widget.ConstraintLayout>
โค้ด: เลือกทั้งหมด
<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">
</RelativeLayout>
1) ImageView ใส่รูปตามที่กำหนด ชื่อไฟล์รูป abc
โค้ด: เลือกทั้งหมด
<ImageView
android:id="@+id/imageView"
android:layout_width="153dp"
android:layout_height="139dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginRight="121dp"
android:layout_marginBottom="522dp"
android:src="@drawable/abc" /> //ไฟล์รูปชื่อ abc
โค้ด: เลือกทั้งหมด
<TextView
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="209dp"
android:text="Login"
android:textSize="35dp" />
โค้ด: เลือกทั้งหมด
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginStart="-3dp"
android:layout_marginLeft="-3dp"
android:layout_marginTop="179dp"
android:layout_marginEnd="3dp"
android:layout_marginRight="3dp"
android:focusable="true"
android:hint="Enter Name"
android:textColorHighlight="#ff7eff15"
android:textColorHint="#ffff25e6" />
โค้ด: เลือกทั้งหมด
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/editText"
android:layout_alignEnd="@+id/editText"
android:layout_alignRight="@+id/editText"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="-3dp"
android:layout_marginLeft="-3dp"
android:layout_marginTop="9dp"
android:layout_marginEnd="-3dp"
android:layout_marginRight="-3dp"
android:ems="10"
android:hint="Password"
android:inputType="textPassword"
android:textColorHint="#ffff299f" />
โค้ด: เลือกทั้งหมด
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginEnd="-9dp"
android:layout_marginRight="-9dp"
android:layout_marginBottom="138dp"
android:layout_toStartOf="@+id/textview"
android:layout_toLeftOf="@+id/textview"
android:text="login" />
โค้ด: เลือกทั้งหมด
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginStart="-6dp"
android:layout_marginLeft="-6dp"
android:layout_marginBottom="137dp"
android:layout_toEndOf="@+id/textview"
android:layout_toRightOf="@+id/textview"
android:text="Cancel" />