下面是一段简单的代码:可以实现hello居右。但是如果将android:orientation="vertical"改成  android:orientation="horizontal"就一直居左。望大神给予指点!谢谢!
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    
<TextView  
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="hello"
    
    />
</LinearLayout>

解决方案 »

  1.   

    android:orientation="horizontal"  时 Layout_gravity 只有垂直方向上的属性有效,水平方向上的属性都无效
    android:orientation="vertical"    时 刚好相反。所以你改成android:orientation="horizontal" 然后在 Layout_gravity中设置居右是无效的。
      

  2.   

    谢谢,fishmen。再问个问题啊:就是我在android:orientation="vertical" 时,将TextView的属性改成android:layout_width="match_parent"时,也是一直居左。我的理解是:如果layout_width="match_parent"的话,是不是vertical的情况下,水平方向的属性了不起作用了。请指教,谢谢。
      

  3.   

    谢谢,fishmen。再问个问题啊:就是我在android:orientation="vertical" 时,将TextView的属性改成android:layout_width="match_parent"时,也是一直居左。我的理解是:如果 layout_width="match_parent"的话,是不是vertical的情况下,水平方向的属性了不起作用了。请指教,谢谢。
      

  4.   

    layout_width="match_parent" == android:layout_height="fill_parent"直接填充满整个父view的空间。跟水平方向上的属性没有什么联系。