2013-05-26 56 views
0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/main_screen_image" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    tools:context=".MainActivity" > 
    <Button 
     android:id="@+id/button1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/facebook_login_button" /> 

    <Button 
     android:id="@+id/button2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/button1" 
     android:layout_centerHorizontal="true" 
     android:background="@drawable/have_a_look_text_image" /> 

</RelativeLayout> 

任何機構可以告訴我爲什麼沒有得到顯示BUTTON2,我真的無法弄清楚按鈕是沒有得到顯示在相對佈局

+0

@油,我做了,但沒有顯示。 – Naga

回答

1

由於Button1的對準父母的底部

android:layout_alignParentBottom="true" 

和BUTTON2被要求低於Button1的

android:layout_below="@id/button1" 

所以BUTTON2是不可見

+0

Ohhh這樣做的竅門,但我想button1只是在底層以上,所以我使用正確的佈局,或者我應該使用相對佈局?我的道歉,如果不是很清楚 – Naga

+1

我會把兩個按鈕放入一個垂直的LinearLayout,並根據需要將該LinearLayout對齊到一個RelativeLayout中。另一方面,我不確定我是否理解你想要按鈕。 –

+0

讓我試試亞歷克斯。十分感謝你的幫助。同時我的佈局設計不好,你能告訴我任何好的網站或資源,我可以學習GUI設計嗎? – Naga