Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide linearlayout from java code? [closed]

Tags:

android

I want to hide the linear layout so i used

LinearLayout mainLayout=(LinearLayout)this.findViewById(R.id.mainLayout); mainLayout.setVisibility(2); 

but why is doesn't hide ??!!!

like image 356
Adham Avatar asked Nov 19 '10 15:11

Adham


People also ask

How do you hide a view in Java?

Use with setVisibility(int) and android:visibility . This view is invisible, and it doesn't take any space for layout purposes. Use with setVisibility(int) and android:visibility .

How do you hide layout?

You can also set the visibility in your layout. xml if you want it hidden when your application first starts. android:visibility="gone" should do the trick. This way it is hidden from the very start when the layout is initialized by your app.

How do I hide a view?

Step 1: Tap on three-dots icon available in the top right side of your post. Step 2: Tap Hide like counts or Hide like and view counts to turn this setting on. Step 3: Tap Unhide Like Counts or Unhide like and view counts to turn this setting off.

Can we use Relativelayout inside LinearLayout?

Using Linear Layout Inside Relative Layout With Example In Android Studio. Linear Layout can be used inside relative layout since one layout can be nested in other layout in XML.


2 Answers

Use:

mainLayout.setVisibility(LinearLayout.GONE); 
like image 64
james Avatar answered Oct 02 '22 11:10

james


You can also set the visibility in your layout.xml if you want it hidden when your application first starts. android:visibility="gone" should do the trick. This way it is hidden from the very start when the layout is initialized by your app.

like image 29
Marc Bernstein Avatar answered Oct 02 '22 11:10

Marc Bernstein