请教大家一个问题,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 控件 右对齐
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。