コードデモ:
<?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”
tools:context=".MainActivity">
<RelativeLayout
android:background="#FFFF00"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.8">
<LinearLayout
android:layout_marginLeft="100dp"
android:layout_marginRight="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="150dp">
<ImageView
android:layout_width="0dp"
android:layout_height="100dp"
android:layout_weight="0.5"
android:src="@drawable/icon_bic">
</ImageView>
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="110dp"
android:layout_weight="1"
android:text="工巢"
android:textColor="#000000"
android:textSize="70dp"
></TextView>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:paddingLeft="80dp"
android:paddingRight="80dp"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<EditText
android:layout_marginHorizontal="40dp"
android:layout_marginTop="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入账号"
android:textColor="@android:color/black"
/>
<ImageView
android:layout_marginTop="36dp"
android:layout_width="30dp"
android:layout_height="60dp"
android:src="@drawable/icon_phone">
</ImageView>
<ImageView
android:layout_marginTop="90dp"
android:layout_width="30dp"
android:layout_height="60dp"
android:src="@drawable/icon_email">
</ImageView>
<EditText
android:layout_marginHorizontal="40dp"
android:layout_marginTop="100dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入验证码"
android:textColor="@android:color/black" />
<Button
android:layout_marginTop="180dp"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="80dp"
android:text="登录"
></Button>
</RelativeLayout>
1:主にLinearLayoutレイアウトを使用し、RelativeLayout相対レイアウトを使用できることを学びます。最初に相対レイアウトを使用して2つの部分に分割します
。2:使用する必要のある画像をリソースフォルダーに追加します
。3:最初の部分はセットアップです。背景色、写真やテキストを追加
4:画像とテキストの2番目の部分、およびログインボタンを追加します。この色は通常の黄色ではなく、Color Copによって取得されます)
運転結果