Android: Hide Imageview

后端 未结 3 1277
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-08 19:34

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



        
相关标签:
3条回答
  • 2020-12-08 20:09

    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

    0 讨论(0)
  • 2020-12-08 20:14

    Initially to set the image view to hidden mode, try

    imageview.setVisibility(View.INVISIBLE);
    

    and when login is successfull, change its visiblity to VISIBLE,

    imageview.setVisibility(View.VISIBLE);
    
    0 讨论(0)
  • 2020-12-08 20:15

    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.

    0 讨论(0)
提交回复
热议问题