2015-11-02 39 views
0

中顯示下面的textview按鈕,我有兩個按鈕在相同的位置,他們將根據可見性集執行他們的功能。現在我想將兩個textviews 下面的按鈕,我希望文本的意見是以下兩個按鈕,所以我用如何在下面的xml佈局的relativeLayout

android:layout_below="@id/actConnect2_btn_connect" 

,但在運行時,當連接按鈕是可見的文本視圖下方出現,如果雙按鈕是可見的它重疊

如何在兩個按鈕下面顯示textview?

注:我知道我可以使用Android:佈局:marginTop,但我想解決它,沒有它

代碼

<Button 
    android:id="@+id/actConnect2_btn_pair" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/actConnect2_tv_label_devClass" 
    android:layout_centerInParent="true" 
    android:text="@string/str_pair"/> 

<Button 
    android:id="@+id/actConnect2_btn_connect" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/str_connect" 
    android:layout_below="@+id/actConnect2_tv_label_devClass" 
    android:layout_alignParentStart="true" /> 

<TextView 
    android:id="@+id/actConnect2_tv_label_uuids" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/actConnect2_btn_connect" 
    android:text="Service's UUID: "> 
</TextView> 

<TextView 
    android:id="@+id/actConnect2_tv_uuids" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@id/actConnect2_tv_label_uuids"> 
</TextView> 

回答

1

採取兩個按鈕在一個佈局

<RelativeLayout android:id="@+id/relativeButton" 
    android:layout_width="wrap_content" 
    android:layout_below="@id/actConnect2_tv_label_devClass" 
    android:layout_height="wrap_content"> 
    <Button 
    android:id="@+id/actConnect2_btn_pair" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    android:layout_centerInParent="true" 
    android:text="@string/str_pair"/> 

<Button 
    android:id="@+id/actConnect2_btn_connect" 
     android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/str_connect" 

    android:layout_alignParentStart="true" /> 
</RelativeLayout> 

,你必須把按鈕佈局(任何類型,並相應安排他們) 分配一個ID,該佈局使用此爲您的TextView

android:layout_below="@id/relativeButton" 
6

把這兩樣在LinearLayout中的按鈕,然後把TextView的下面的LinearLayout

2

。 將textView放置在該佈局ID下方。