Skip to content
This repository has been archived by the owner on Jan 29, 2021. It is now read-only.

onClickState drawable resource disappearing #81

Open
summers314 opened this issue Mar 23, 2016 · 1 comment
Open

onClickState drawable resource disappearing #81

summers314 opened this issue Mar 23, 2016 · 1 comment

Comments

@summers314
Copy link

When applying the drawable state; ?android:attr...selectableitembackground ; the item highlights but once the drag starts it disappears. There is a hack to solve this using an view-overlay, but that becomes too intensive on memory. Seems too much effort just to get an overlay when the item is clicked

@summers314
Copy link
Author

This happens cuz the library takes a snapshot of the item (which does not include the touch-overlay)

Solution:

xml:

Edit this method in DynamicGridView

/**
* Creates the hover cell with the appropriate bitmap and of appropriate
* size. The hover cell's BitmapDrawable is drawn on top of the bitmap every
* single time an invalidate call is made.
*/
private BitmapDrawable getAndAddHoverView(View v) {

    int w = v.getWidth();
    int h = v.getHeight();
    int top = v.getTop();
    int left = v.getLeft();

    Bitmap b = getBitmapFromView(v);

    BitmapDrawable drawable = new BitmapDrawable(getResources(), b);

    mHoverCellOriginalBounds = new Rect(left, top, left + w, top + h);
    mHoverCellCurrentBounds = new Rect(mHoverCellOriginalBounds);

    drawable.setBounds(mHoverCellCurrentBounds);

//Choose the color according to your theme
drawable.setColorFilter(Color.parseColor("#994dace3"), PorterDuff.Mode.SRC_OVER);

    return drawable;
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant