teekib teekib - 1 month ago 6
Android Question

Android: Hide Imageview

ihave a imageveiw intially 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 success i should show the image
Any suggestions will be helpful..thankyou

Answer

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 show.

GONE - Both space and widget is invisible.

Comments