3

I have an ImageButton that is 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"/>

On the activity I change It's 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 APIs 21 and 22 doesn't work

This is the declaration of the ImageButton:

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

Thank you for the help.

N J
  • 27,217
  • 13
  • 76
  • 96
VasFou
  • 1,561
  • 1
  • 22
  • 39
  • Have you set breakpoints to verify that you set correct visibility to `imageButton`? – Mikhail Jul 16 '15 at 15:41
  • Eventually i have found the problem , because i don't have lollipop device i use emulator and the checking of visibility is inside a if (scrollState == SCROLL_STATE_IDLE) so because i have a mouse and i use the scroll button of the mouse the scroll state doesn' t working but if i scroll my list view with the mouse like touching the screen it's working – VasFou Jul 16 '15 at 15:46

1 Answers1

0

I had this issue but later i have discovered that this is related to the settings in a lollipop device.

Here are the three options described here: Lollipop Notification setVisibility() Does Not Work?

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

  • Hide sensitive notification content respects the new visibility types.

  • Don't show notifications at all will make all notifications effectively secret.

Community
  • 1
  • 1
Jorgesys
  • 124,308
  • 23
  • 334
  • 268