lopspower / CircularImageView

Create circular ImageView in Android in the simplest way possible
Apache License 2.0
1.95k stars 413 forks source link

How can you set the shadow center location? #33

Closed agramian closed 6 years ago

agramian commented 8 years ago

Currently the shadow is drawn slightly offset from the center of the ImageView so that the shadow is visibly thicker on the bottom than the top. Is it possible to center the shadow so that it is even all the way around the image?

Rainer-Lang commented 8 years ago

+1

Leonid-Kiev commented 8 years ago

seems you can only extend this View and change the drawShadow method:

private void drawShadow(float shadowRadius, int shadowColor) {
        this.shadowRadius = shadowRadius;
        this.shadowColor = shadowColor;
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) {
            setLayerType(LAYER_TYPE_SOFTWARE, paintBorder);
        }
        paintBorder.setShadowLayer(shadowRadius, 0.0f, 0.0f, shadowColor);
    }
lopspower commented 6 years ago

Fix in https://github.com/lopspower/CircularImageView/commit/271b47dd4f74475af66dc8e72a5b045b89f1a83e You can now set shadowGravity with setShadowGravity method or with civ_shadow_gravity (center, top, bottom, start or end)