[英]How to achieve this layout in Android using Android Studio
我正在嘗試在Android Studio中實現以下布局,但似乎無法正常工作。
我到目前為止:
<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"
tools:context="net.firstapp.myapplication.Main">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="text" // I want this to be a dropdown with options male and female
android:text="Name"
android:ems="10"
android:id="@+id/editText" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:ems="10"
android:id="@+id/editText2" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPostalAddress"
android:ems="10"
android:id="@+id/editText3" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="number"
android:ems="10"
android:id="@+id/editText4" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Name"
android:ems="10"
android:id="@+id/editText5" />
<TextView
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="@+id/editText6" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="phone"
android:ems="10"
android:id="@+id/editText7" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button2" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button3" />
<Button
android:text="Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button4" />
</FrameLayout>
我是Android的新手,我不確定應該怎么做-我正在努力進行上述布局。
對於下拉列表,您可以使用Spinner
:
https://www.tutorialspoint.com/android/android_spinner_control.htm
管理布局你應該使用RelativeLayout
。所以你可以將它們與性能管理讓您的視圖RelativeLayout
像LEFT_OF
, RIGHT_OF
等:
https://developer.android.com/reference/android/widget/RelativeLayout.html
https://www.mkyong.com/android/android-relativelayout-example/
您正在使用框架布局作為層次結構中的父視圖。 通常,框架布局僅包含一個子視圖。 它不會讓您實現這種類似於列表的視圖。 在此處查看更多信息: FrameLayouts
在這里,您最好的選擇是使用垂直LinearLayout作為父級。 有些LinearLayouts也必須成為父級LinearLayout的子級(對於並排放置的視圖),請參見此處: LinearLayouts
RelativeLayouts似乎也是一個不錯的選擇
這會帶你去。
<ScrollView>
<RelativeLayout>
<Spinner>
<EditText> //add minLines property
<RelativeLayout>
<EditText paddingRight="width of image view">
<ImageView alignParentRight=true>
</RelativeLayout>
<RelativeLayout>
<EditText>
<EditText> //use rightOf property
</RelativeLayout>
<TextView marginTop="20dp">
<EditText>
<EditText>
<RelativeLayout>
<TextView width="match_parent" leftOf="view">
<View width="1dp" centerHorizontal="true">
<TextView with ="match_parent" rightOf="view">
</RelativeLayout>
<TextView>
</RelativeLayout>
</ScrollView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.