Pat_B

Invisible button issue

Discussion created by Pat_B on Mar 30, 2012
Latest reply on Mar 30, 2012 by Pat_B
Hi!

Okay, so I have a button in a map view that I'm trying to turn on/off (it's for showing turn by turn directions, so it only needs to be shown when there's a route on the map).

The button is defined in my xml as:

  <Button    
  android:id = "@+id/turnbtn"
   android:layout_height="wrap_content"    
  android:layout_width="wrap_content"    
  android:text= "@string/turnbyturn"    
   android:layout_alignParentBottom="true"
   android:layout_alignParentRight="true"
   android:visibility="invisible"
/>

I set the button to visible using:

         Button btn = (Button)p.findViewById(R.id.turnbtn);
         btn.setVisibility(View.VISIBLE);

On my phone it works fine (htc incredible), but on a galaxy tablet (and other newer devices) the button flickers on and off or doesn't show up at all until I pan the underlying map.  After panning it acts as expected.  When the button isn't being shown, it still activates if I click the right spot.  I've tried calling invalidate, forceLayout, bringToFront, etc with no joy, tried defining it as visible initially and then turning it off during onCreate, I even tried programatically panning the map (last resort). I have other buttons floating on the map (zoom in/out) that are on all the time and don't have this problem.  Seems like a conflict of some sort with drawing the map and the button visibility (bug), if anyone can recommend a work around that'd be awesome!

Thanks,
Pat

Outcomes