Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images including drop shadows #10

Closed
Gorcyn opened this issue Dec 23, 2013 · 3 comments
Closed

Images including drop shadows #10

Gorcyn opened this issue Dec 23, 2013 · 3 comments

Comments

@Gorcyn
Copy link

Gorcyn commented Dec 23, 2013

There is an annoying bug with images including drop shadows.

With this sample image for example :
https://dl.dropboxusercontent.com/s/da9c10jdtk4g0c0/98014_presentations-01.png

I used a vertical LinearLayout to contain an ImageView and a TextView.
Every time I scroll, the drop shadow of the image is like doubled, as if the Bitmap was drawn over the previous one at each call of the draw function.

I understand the problem but I can't find how to fix it.

@Gorcyn
Copy link
Author

Gorcyn commented Dec 27, 2013

I found a way to let the view keep its render in cache... a comment dropped me an hint.
The application I'm working on targets 4.0+ (so are my tests devices) so I didn't tried to use the cache before the version test.

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
    @Override
    protected void dispatchDraw(Canvas canvas) {
        View childView = getChildAt(0);

        if (childView != null) {

            // If on honeycomb or newer, cache the view.
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
                if (childView.isDirty() && !childView.isDrawingCacheEnabled()) {
                    childView.draw(this.wrappedViewDrawingCanvas);

                    // Edited by @Gorcyn
                    {
                        childView.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
                        childView.setDrawingCacheEnabled(true);
                    }
                    if (this.isReflectionEnabled) {
                        this.createReflectedImages();
                    }
                }
            } else {
                childView.draw(this.wrappedViewDrawingCanvas);
            }
        }

        canvas.drawBitmap(this.wrappedViewBitmap, (this.getWidth() - childView.getWidth()) / 2, 0, this.paint);
    }

That could help!

@DjulLau
Copy link

DjulLau commented Aug 28, 2014

Thanks a lot for this workaround !

@davidschreiber
Copy link
Owner

Sorry but I no longer maintain this project. I will still keep this project as reference for future visitors but I highly recommend to implement the coverflow itself using Android's new RecyclerView.

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

No branches or pull requests

3 participants