2011-08-06 27 views
0

在这里你可以看到我在更长的linearLayout3中获得了LL_BtnR布局。 LL_BtnR的重力被设置为'中心',但无论如何,它出现在左上角。布局元素不会居中...为什么?

任何想法如何获得linearLayout3中心的内容?

enter image description here

谢谢!

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout android:id="@+id/linearLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:background="@layout/backrep" android:orientation="vertical" android:layout_gravity="center"> 
     <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/linearLayout2" android:background="@drawable/spell_frame" android:layout_marginBottom="10px" android:layout_marginTop="5px" android:layout_gravity="center"> 
      <TextView android:text="TextView" android:textColor="#FFFFFF" android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingTop="7px" android:paddingLeft="15px" android:typeface="sans"></TextView> 
     </LinearLayout> 


     <LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/linearLayout3" android:layout_marginLeft="5px" android:layout_marginRight="5px" android:layout_gravity="center"> 

      <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5px" android:layout_marginBottom="5px" android:layout_marginRight="5px" android:layout_marginTop="5px" android:id="@+id/LL_BtnR" android:onClick="onButtonClick" android:layout_gravity="center"> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/ImageView01" android:src="@drawable/button_left" android:layout_width="wrap_content"></ImageView> 
       <FrameLayout android:id="@+id/frameLayout1" android:layout_height="match_parent" android:background="@layout/butrep" android:layout_width="40px" android:layout_gravity="center"> 
        <ImageView android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/bun_r" android:id="@+id/imageView2" android:layout_gravity="center"></ImageView> 
       </FrameLayout> 
       <ImageView android:layout_height="wrap_content" android:id="@+id/imageView1" android:layout_width="wrap_content" android:src="@drawable/button_right"></ImageView> 
      </LinearLayout> 

     </LinearLayout> 

    </LinearLayout> 

回答

1

将包围LinearLayout的重力更改为中心。

+0

完成...相同,不会改变任何东西。 – Roger

+0

你可以发布你的xml这个布局文件吗?上面加了 – PravinCG

+0

。 :) – Roger

相关问题