首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > Android >

LinearLayout里上下两个TextView,希望下边的这个,跟上边那个右对齐。如何做

2013-04-09 
LinearLayout里上下两个TextView,希望下边的这个,跟上边那个右对齐。怎么做?请教大家一个问题,LinearLayout

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。 

热点排行