如题, 麻烦大家看看小弟下面这个布局哪里不对,,怎么就只能显示Button1和Button2呢?<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:gravity="center"
     >
    <Button android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
            android:text="button1"
        />
     
    <Button android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button2"
        android:layout_toRightOf="@id/button1"
        android:layout_below="@id/button1"
        />
     
    <Button android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button3"
        android:layout_toRightOf="@id/button1"
        android:layout_above="@id/button1"
        />
     
    <Button android:id="@+id/button4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button4"
        android:layout_toLeftOf="@id/button1"
        android:layout_below="@id/button1"
        />
     
     
    <Button android:id="@+id/button5"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="button5"
        android:layout_toLeftOf="@id/button1"
        android:layout_above="@id/button1"
        />
</RelativeLayout>
relativelayout布局

解决方案 »

  1.   

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:gravity="center" >    <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerInParent="true"
            android:text="button1" />    <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/button1"
            android:layout_toRightOf="@id/button1"
            android:text="button2" />    <Button
            android:id="@+id/button3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/button1"
            android:layout_toRightOf="@id/button1"
            android:text="button3" />    <Button
            android:id="@+id/button4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@id/button1"
            android:layout_toLeftOf="@id/button1"
            android:text="button4" />    <Button
            android:id="@+id/button5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@id/button1"
            android:layout_toLeftOf="@id/button1"
            android:text="button5" /></RelativeLayout>
    这样就可以了,试试吧
      

  2.   

    你是想做成中间一个按扭,然后此按扭的四个方向对应一个么?
    你试下一楼的写法 应该是可以 的。
    如果不行,你button1和button2不是已经布好了么,然后其它的以button1和button2来相对,
    比如说,1在中间,2在左上,3在左下: 3below1,同时3也与2左边对齐,以此类推。
    另外,你可以看eclipse上写layout时可以直接看UI的
      

  3.   

    --嗯, 真的可以了额...多谢多谢..
    就多了一个设置Button1在父窗体的中间就可以了..这是为什么呢?