私は相対的なレイアウトを学び、ログインページをシミュレートするための小さなテストレイアウトを作成しました。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:id="@+id/labelUsername"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="username:"
android:layout_centerVertical="true"/>
<EditText android:id="@+id/txtUsername"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="input username here"
android:layout_toRightOf="@id/labelUsername"
android:layout_alignBaseline="@id/labelUsername"/>
<TextView android:id="@+id/labelPassword"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="password:"
android:layout_below="@id/txtUsername"
android:layout_alignParentLeft="true"/>
<EditText android:id="@+id/txtPassword"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:hint="input password here"
android:layout_below="@id/txtUsername"
android:layout_alignLeft="@id/txtUsername"
android:layout_alignBaseline="@id/labelPassword"/>
</RelativeLayout>
私が欲しいのは、Username Label
とをとTextfield
の上にPassword Label
置くことですTextField
。しかし、結果は元に戻され、パスワードは上にあります!
問題はの「android:layout_below」プロパティだと思います。labelPassword
以下に設定すると機能しますが、ラベルよりもはるかに大きいlabelUsername
ため、この場合は両方がオーバーレイされます。なので、以下を作ってみますが、おかしな動作で、わかりません。textfield
textfields
labelPassword
txtUsername
ちなみに、相対レイアウトでレイアウトを作成する際のガイドラインはありますか?
最初は何を置けばいいですか?
やっと何を入れたらいいの?
ありがとう!