1. Are you ready for the Galaxy S20? Here is everything we know so far!

Android ImageView Visibility help

Discussion in 'Android Development' started by Nicknumber, Nov 1, 2010.

  1. Nicknumber

    Nicknumber Lurker
    Thread Starter

    I have an ImageView object, x, loaded into my application. I want to toggle its visibility by clicking a button in the same activity. I have this code:


    if(x.getVisibility() == INVISIBLE)
    {
    x.setVisibility(VISIBLE);
    }

    elseif(x.getVisibility() == VISIBLE)
    {
    x.setVisibility(INVISIBLE);
    }


    The default visibility setting is set to VISIBLE. When I click the button, the image won't vanish. Does anyone know how to fix this?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. vinay1497

    vinay1497 Lurker

    Hello,

    In your Layout xml file you can give the image visibility with "android:visibility="invisible" "

    And in your .java file

    x.setVisibility(1); // it will be visible if set to 0 invisible


    Good luck

    Thanks
    Vinay Guntaka
     
    Nicknumber likes this.
Loading...
Similar Threads - Android ImageView Visibility
  1. dorlow
    Replies:
    4
    Views:
    174
  2. Hajji Abdoullah
    Replies:
    5
    Views:
    239
  3. Hajji Abdoullah
    Replies:
    3
    Views:
    199
  4. Sleep Sounds
    Replies:
    3
    Views:
    205
  5. Sleep Sounds
    Replies:
    1
    Views:
    140
  6. edgie70
    Replies:
    5
    Views:
    319
  7. Youssef Hammad
    Replies:
    0
    Views:
    223
  8. sunny026
    Replies:
    2
    Views:
    248
  9. RATKEN
    Replies:
    0
    Views:
    1,005
  10. David Ramer
    Replies:
    0
    Views:
    452

Share This Page

Loading...