7

Is it possible to have ripple effect on button which is part of remoteviews?(notification with custom layout or widget)

I tried to set button background to drawable notification_material_media_action_background:

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
        android:color="@color/ripple_material_dark"/>

but it doesn't have effect. Same background is used in Notification source code and there is ripple effect on notification buttons. This is code from Notification source which creates action button(with ripple effect):

   private RemoteViews More ...generateMediaActionButton(Action action) {
            final boolean tombstone = (action.actionIntent == null);
            RemoteViews button = new RemoteViews(mBuilder.mContext.getPackageName(),
                    R.layout.notification_material_media_action);
            button.setImageViewResource(R.id.action0, action.icon);
            button.setDrawableParameters(R.id.action0, false, -1,
                    0xFFFFFFFF,
                    PorterDuff.Mode.SRC_ATOP, -1);
            if (!tombstone) {
                button.setOnClickPendingIntent(R.id.action0, action.actionIntent);
            }
            button.setContentDescription(R.id.action0, action.title);
            return button;
        }

Only difference seems to be with this line:

 button.setDrawableParameters(R.id.action0, false, -1,
                        0xFFFFFFFF,
                        PorterDuff.Mode.SRC_ATOP, -1);

but this method is @hide so it can't be called.

Any idea how to add ripple effect? Thanks!

Martin Vandzura
  • 3,047
  • 1
  • 31
  • 63

1 Answers1

0

For ImageButton ,use this attribute in its tag :


 android:background="?android:attr/actionBarItemBackground"

A.G
  • 87
  • 1
  • 8