我不知道到底是什么问题,但只是想澄清一些事情。
我使用的是LinearLayout
我的目标是让一个文本字符串 "example "走到一个EditText视图的下方,似乎每当我尝试使用margins移动视图并尝试将它们居中时,它们最终总是走到彼此相反的方向,你们有什么建议来解决这个问题吗?
你可以使用Relativelayout作为父Layout和定位你的部件相对于其他使用他们的idyou可以把这个代码在你的textview xml定义。
layout_below:@上面的那个人的名字
LinearLayout
定义 android:orientation:vertical
允许您在列表中定位您添加的每个视图。
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textAutoComplete"/>
<TextView
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Message"/>
</LinearLayout>
相对布局
定义 android:layout_below="id_view"
其中,id_view是将被优先处理的视图的id。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textAutoComplete"/>
<TextView
android:layout_below="@id/edit_text"
android:id="@+id/text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Message"/>
</RelativeLayout>