Reputation: 1
in the below xml layout, i have two buttons at the same position and they will do their function based on the visibilty set. now i tried to place two textviews below the buttons, i want the text views to be below both buttons so I used
android:layout_below="@id/actConnect2_btn_connect"
but at run time when the connect-button is visible the text view appears below it, and if pair-button is visible it overlap
how to display the textview below both buttons?
Note: i know that i can use android:layout:marginTop but i want to solve it without it
code:
<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>
Upvotes: 1
Views: 4164
Reputation: 155
You have to place the buttons in a Layout (any type and arrange them accordingly) Assign an ID to that layout. Place the textView below that layout ID.
Upvotes: 2
Reputation: 35549
take both button in one layout
<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>
and use this for your textview
android:layout_below="@id/relativeButton"
Upvotes: 2
Reputation: 436
Put both buttons in a LinearLayout then put the textview below the LinearLayout
Upvotes: 6