I have the following layout
<merge> <LinearLayout android:id="@+id/ll_main" android:layout_height="fill_parent" android:layout_width="fill_parent" /> <LinearLayout android:id="@+id/ll_sub" android:layout_height="fill_parent" android:layout_width="fill_parent" /> </merge>
What I want to do is show / hide the ll_sub layout at runtime via setVisibility() , but it does not work.
When I set android:visibility="gone" (also I checked with invisible ) from xml ll_sub , it does not appear on the screen, and this time when I use setVisibility() to show this layout at runtime, it displays but when I try to hide this layout after showing it, it is not hiding.
EDIT
I am trying to show / hide this linear layout with the click of a button.
LinearLayout ll; Button minimize; int visibility=0; @Override public void onCreate(Bundle savedInstanceState) { ll=(LinearLayout)findViewById(R.id.ll_sub); minimize=(Button)findViewById(R.id.minimize); minimize.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if(visibility==0) { visibility=2; } else { visibility=0; } ll.setVisibility(visibility); } }); }
android android-layout
Vinod Maurya Apr 13 2018-11-11T00: 00Z
source share