读书人

LinearLayout里上下两个TextView希望

发布时间: 2013-04-09 16:45:09 作者: rapoo

LinearLayout里上下两个TextView,希望下边的这个,跟上边那个右对齐。怎么做?
请教大家一个问题,LinearLayout里上下两个TextView,希望下边这个,跟上边那个右对齐。上边那个的layout_marginLeft不能动,即不能让它在LinearLayout里靠右边;只是希望下边TextView向它右对齐。目前是左对齐。

怎么做?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:text="@string/str_content1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20sp" android:layout_marginLeft="10sp" >
</TextView>

<TextView
android:text="@string/str_content2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20sp"
android:layout_marginLeft="10sp" >
</TextView>
</LinearLayout> LineaLayout?控件?右对齐
[解决办法]
相对布局试试。
[解决办法]
用相对布局,其中一个属性是
layout_alignRight :当前元素与指定的元素右对齐
在下面的textview中定义属性:android:layout_alignRight="@id/abc"。这里“abc”是上面的textview的ID。

读书人网 >Android

热点推荐