android layout hide/show views
android, android-layout, android-linearlayout
Solution
use-
button.setVisibility(View.GONE);
Problem
I have a linear vertical layout as below. I need in my application to switch the Button and the TextView. To hide button and show text then change etc. If I use setVisibility(View.INVISIBLE) for the button it disappears from the screen but it still hold the place. How can I switch those elements without remove them completely? ``` <Chronometer android:id="@+id/chronometer1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:textSize="30sp" android:text="Chronometer" /> <Button android:id="@+id/stopButton" style="?android:attr/buttonStyleSmall" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/stop_button" /> <TextView android:id="@+id/wrongCounter" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="bottom|center_horizontal" android:textSize="30sp" android:text="" /> ```