1、编辑activity_login.xml如下:
<LinearLayout 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="@drawable/login_back"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".LoginActivity" >
<RelativeLayout
android:id="@+id/RelativeLayout01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="100dp" >
<ImageView
android:id="@+id/userImg"
android:layout_width="25dp"
android:layout_height="40dp"
android:background="@drawable/login_user" />
<EditText
android:id="@+id/et_phone"
android:layout_width="175dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_marginBottom="5.0px"
android:layout_marginLeft="0.5dip"
android:layout_marginRight="5.0dip"
android:layout_marginTop="0dp"
android:layout_toRightOf="@+id/userImg"
android:background="@android:color/white"
android:hint="@string/pleaseenterphonenumber"
android:inputType="number"
android:maxLength="10"
android:paddingLeft="20sp"
android:saveEnabled="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginTop="20dp" >
<ImageView
android:id="@+id/pwdImg"
android:layout_width="25dp"
android:layout_height="40dp"
android:background="@drawable/login_pwd" />
<EditText
android:id="@+id/et_pwd"
android:layout_width="175dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_marginBottom="5.0px"
android:layout_marginLeft="0.5dip"
android:layout_marginRight="5.0dip"
android:layout_marginTop="0dp"
android:layout_toRightOf="@+id/pwdImg"
android:background="@android:color/white"
android:hint="@string/pleaseinoutpassword"
android:inputType="number"
android:maxLength="10"
android:paddingLeft="20sp"
android:saveEnabled="true" />
</RelativeLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="76dp"
android:layout_marginTop="20dp"
android:orientation="horizontal" >
<Button
android:id="@+id/btn_login"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="150dp"
android:layout_height="50dp"
android:background="@drawable/login_btn" />
<Button
android:id="@+id/btn_regist"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:alpha="100"
android:text="立即注册"
android:textColor="@android:color/darker_gray"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
2、布局效果如下: