Display a Button with visibility Gone Android -
i have linear layout 3 buttons, , linear layout overlays previous layout. need still show 1 of buttons first layout. how can achieve that? here code far:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="center_vertical|center_horizontal|center" android:layout_marginbottom="10dp" android:layout_marginleft="85dp" android:layout_marginright="85dp" android:layout_margintop="20dp" android:orientation="vertical" android:padding="10dp" android:screenorientation="portrait" > <button android:id="@+id/fire_help" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center_vertical|center_horizontal|center" android:layout_marginbottom="30dp" android:layout_weight="1" android:background="@drawable/fire_help" android:text="@string/fire_service" android:textcolor="@color/white" android:textstyle="bold" /> <button android:id="@+id/police_help" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center_vertical|center_horizontal|center" android:layout_marginbottom="30dp" android:layout_weight="1" android:background="@drawable/police_help" android:text="@string/police_help" android:textcolor="@color/white" android:textstyle="bold" /> <button android:id="@+id/medical_help" android:layout_width="match_parent" android:layout_height="0dp" android:layout_gravity="center_vertical|center_horizontal|center" android:layout_marginbottom="10dp" android:layout_weight="1" android:background="@drawable/medical_help" android:padding="10dp" android:text="@string/medical_help_description" android:textcolor="@color/white" android:textstyle="bold" android:visibility="visible" > <requestfocus /> </button> </linearlayout> <linearlayout android:id="@+id/overlay" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@color/overlay_background" android:clickable="true" android:orientation="vertical" android:screenorientation="portrait" android:visibility="visible" > <tablerow android:id="@+id/textrow1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/overlay_text_background" > <textview android:id="@+id/test_mode" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical|center_horizontal" android:gravity="center" android:padding="20dp" android:text="@string/test_mode" android:textappearance="?android:attr/textappearancelarge" android:textcolor="@color/white" android:textsize="25sp" android:textstyle="bold" /> </tablerow> <tablerow android:id="@+id/textrow2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@color/white" > <textview android:id="@+id/press_button_text" android:layout_width="fill_parent" android:layout_height="wrap_content" android:padding="20dp" android:text="@string/press_button" android:textappearance="?android:attr/textappearancelarge" android:textsize="16sp" android:textstyle="bold" /> </tablerow> <relativelayout android:id="@+id/overlay_button_layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_marginleft="65dp" android:layout_marginright="65dp" android:layout_margintop="160dp" android:layout_marginbottom="20dp" android:background="@drawable/white_background" android:orientation="vertical" android:padding="25dp" > <button android:id="@+id/overlay_medical_help" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/medical_help" android:padding="10dp" android:src="@drawable/medical_help" android:text="@string/medical_help_description" android:textcolor="@color/white" android:textstyle="bold" android:visibility="visible" > <requestfocus /> </button> </relativelayout> </linearlayout>
here how can programatically
view b = findviewbyid(r.id.button); b.setvisibility(view.gone); or in xml:
<button ... android:visibility="gone"/>
Comments
Post a Comment