Image button visibility not working on devices with lollipop and above

I have ImageButton

which by default invisible

:

  <ImageButton
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/anchor"
    android:src="@drawable/anchor"
    android:elevation="6dp"
    android:layout_below="@+id/rl_row_progress_bar"
    android:layout_centerHorizontal="true"
    android:visibility="invisible"/>

      

In action, I am changing this attribute with this code:

 if(lastPotition == 1){
    mImageButton.setVisibility(View.GONE);
 } else{
    mImageButton.setVisibility(View.VISIBLE);
 }

      

The problem is that in pre lollipop the Image button works fine, but in API 21 and 22 it doesn't work

This declaration ImageButton

:

private ImageButton mImageButton;
mImageButton =(ImageButton)v.findViewById(R.id.anchor); //anchor

      

Thanks for the help.

+3


source to share


1 answer


I had this problem, but later I found it was due to the settings in the lollipop device.

Here are the three options described here: Lollipop Notification setVisibility () not working?



  • Show all notification content makes all notifications (regardless of visibility) effectively public.

  • Hide sensitive content for notifications matches the new visibility types.

  • Do not show notifications at all will make all notifications effectively secret.

0


source







All Articles