[英]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.