我将红色标签设计layout.xml
为如图所示彼此放置在一起,但是从相同的起点“黑线”开始,我尝试了这一部分但无法处理。
请参阅下面的xml文件。我试图将layout_width
每个标记为红色的视图更改为,match_parent
但这会使标签从最左边开始,就好像它们是alignedToParentLeft。请让我知道我应该在布局中添加些什么,以使视图从黑线开始?
xml:
<RelativeLayout
android:id="@+id/reportRealtiveLayout02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical">
<TextView
android:id="@+id/reportLocNameLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name: "
android:textColor="@android:color/holo_red_dark"/>
<TextView
android:id="@+id/reportLocNameValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/reportLocNameLabel"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/reportRealtiveLayout03"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical">
<TextView
android:id="@+id/reportLocLatLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lat: "
android:textColor="@android:color/holo_red_dark"/>
<TextView
android:id="@+id/reportLocLatValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/reportLocLatLabel"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/reportRealtiveLayout04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical">
<TextView
android:id="@+id/reportLocLngLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lng: "
android:textColor="@android:color/holo_red_dark"/>
<TextView
android:id="@+id/reportLocLngValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/reportLocLngLabel"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/reportRealtiveLayout05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|center_vertical">
<TextView
android:id="@+id/reportTimeLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Time: "
android:textColor="@android:color/holo_red_dark"/>
<TextView
android:id="@+id/reportTimeValue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/reportTimeLabel"/>
</RelativeLayout>
output_Image:
你android:layout_gravity="center|center_vertical"
在每个书里写了RelaviteLayout
。
我建议您删除该行代码。此代码将自动center
为其子代。center_vertical
没关系。但是Center
不是可取的。相反,您也可以使用以下代码。
android:layout_gravity="left|center_vertical"
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句