实现如下图所示的登录界面
三星Galaxy s8截图,忽略图片右侧的拉出按钮(这是三星Galaxy s8上面的曲面侧屏拉出开关)
一、全屏设置:
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
二、布局:
使用FrameLayout
附上布局文件代码
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
tools:context="au.com.joincc.secusoft.LoginActivity">
<ImageView
android:id="@+id/iv_background"
android:layout_width="match_parent"
android:layout_height="1920px"
android:src="@mipmap/login_background"
android:scaleType="fitXY"/>
<LinearLayout
android:id="@+id/linear_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="683px">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp">
<ImageView
android:id="@+id/iv_user"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:src="@mipmap/login_user" />
<EditText
android:id="@+id/et_user"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_toLeftOf="@+id/iv_expansion"
android:layout_toRightOf="@id/iv_user"
android:background="@null"
android:cursorVisible="false"
android:hint="@string/hint_user"
android:textColor="#000"
android:textColorHint="#717070"
android:textSize="15dp"/>
<ImageView
android:id="@+id/iv_expansion"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:src="@mipmap/little_expansion3"
android:scaleType="centerInside"/>
</RelativeLayout>
<View
android:id="@+id/viewDivider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#c1bcbc" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="10dp">
<ImageView
android:id="@+id/iv_paw"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_centerVertical="true"
android:src="@mipmap/login_password" />
<EditText
android:id="@+id/et_paw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="20dp"
android:layout_toLeftOf="@+id/switch_paw"
android:layout_toRightOf="@id/iv_paw"
android:background="@null"
android:cursorVisible="false"
android:password="true"
android:hint="@string/hint_paw"
android:textColor="#000"
android:textColorHint="#717070"
android:textSize="15dp"/>
<ImageView
android:id="@+id/switch_paw"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:src="@mipmap/pwd_off"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#c1bcbc" />
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="40dp"
android:layout_marginRight="40dp"
android:layout_marginTop="20dp"
android:background="@drawable/shape_button2"
android:text="@string/login"
android:textSize="14dp"
android:textColor="#fff" />
</LinearLayout>
</FrameLayout>