Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: Hide Imageview

I have a imageveiw initially it should be in hidden mode,

<ImageView     android:id="@+id/custom"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_gravity="center_vertical|right"         android:src="@drawable/custom1" /> 

and I created a login page ..whenever my login is successful I should show the image.

like image 672
teekib Avatar asked Nov 15 '12 12:11

teekib


People also ask

How to make Image View invisible in android?

You can use setVisibility() method to hide / show the imageView in android studio.

What is adjustViewBounds in android?

android:adjustViewBounds. Set this to true if you want the ImageView to adjust its bounds to preserve the aspect ratio of its drawable. android:baseline. The offset of the baseline within this view.


2 Answers

Try this

Your xml

<ImageView             android:id="@+id/custom"             android:layout_width="wrap_content"             android:layout_height="wrap_content"             android:layout_gravity="center_vertical|right"                 android:src="@drawable/custom1" /> 

You can set here on xml like this

android:visibility="visible" 

or

android:visibility="invisible" 

or

android:visibility="gone" 

Java program

ImageView imgView = (ImageView)findViewById(R.id.custom); 

set your ImageView like this

imgView .setVisibility(View.VISIBLE);  imgView .setVisibility(View.INVISIBLE);  imgView .setVisibility(View.GONE); 

Difference between INVISIBLE and GONE.

INVISIBLE - The widget will be invisible but space for the widget will be shown.

GONE - Both space and widget is invisible.

like image 124
Rajesh Rajaram Avatar answered Sep 20 '22 17:09

Rajesh Rajaram


Set Visibility property of Imageview like this in java

imgView.setVisibility(View.VISIBLE); imgView.setVisibility(View.INVISIBLE); imgView.setVisibility(View.GONE); 

Or like this in XML

android:visibility="visible" android:visibility="invisible" android:visibility="gone" 

Or like this in C#

imgView.Visibility = ViewStates.Visible; imgView.Visibility = ViewStates.Invisible; imgView.Visibility = ViewStates.Gone; 

Result for each will be like this

enter image description here

like image 27
Keyur Lakhani Avatar answered Sep 17 '22 17:09

Keyur Lakhani