效果图:
xml代码如下:
<?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:gravity="center"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="WELCOME"
android:textSize="30dp"
android:textColor="#3F51B5"
android:textStyle="bold"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="50dp">
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/ic_assignment"
/>
<EditText
android:layout_width="280dp"
android:layout_height="40dp"
android:background="@drawable/edit_bg"
android:textSize="20dp"
android:hint="email"
android:paddingLeft="10dp"
android:textColorHint="#995C45A7"
android:inputType="textEmailAddress"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="10dp">
<ImageView
android:layout_width="35dp"
android:layout_height="35dp"
android:background="@drawable/edit_password"
/>
<EditText
android:layout_width="280dp"
android:layout_height="40dp"
android:background="@drawable/edit_bg"
android:textSize="20dp"
android:hint="password"
android:paddingLeft="10dp"
android:textColorHint="#995C45A7"
android:inputType="textPassword"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginTop="25dp">
<Button
android:id="@+id/quxaio"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="取消"
android:textSize="20dp"
android:background="@drawable/button_bg"
/>
<Button
android:id="@+id/denglu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录"
android:textSize="20dp"
android:layout_marginLeft="50dp"
android:background="@drawable/button_bg"
/>
</LinearLayout>
</LinearLayout>
edit_bg样式如下:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="10dp"/>
<stroke
android:width="2dp"
android:color="#3F51B5"/>
</shape>
按钮样式也可根据此编写出来。
图标可选Android Studio自带的图标,方法如下: