You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in #1052 the sizing of the drawable does not work correctly and leads to non-circular shapes. The issue is that you are trying to control the size by setting the bounds on the drawable, but that is problematic because the first time it is drawn Android sets the bounds to the size of the DayView.
I threw together this class that should accomplish what you want. Remove all the code trying to set the bounds of the drawable and instead wrap the drawable in an instance of this class:
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.InsetDrawable;
import androidx.annotation.Nullable;
public class CenterInsideDrawableWrapper extends InsetDrawable {
private Rect tempRect = new Rect();
public CenterInsideDrawableWrapper(@Nullable Drawable drawable) {
super(drawable, 0);
}
@Override
protected void onBoundsChange(Rect bounds) {
tempRect.set(bounds);
final double offset = Math.abs(bounds.height() - bounds.width()) / 2.0;
if(bounds.width() > bounds.height()) {
tempRect.left += Math.floor(offset);
tempRect.right -= Math.ceil(offset);
}
else {
tempRect.top += Math.floor(offset);
tempRect.bottom -= Math.ceil(offset);
}
// Apply inset bounds to the wrapped drawable.
super.onBoundsChange(tempRect);
}
}
The text was updated successfully, but these errors were encountered:
As described in #1052 the sizing of the drawable does not work correctly and leads to non-circular shapes. The issue is that you are trying to control the size by setting the bounds on the drawable, but that is problematic because the first time it is drawn Android sets the bounds to the size of the DayView.
I threw together this class that should accomplish what you want. Remove all the code trying to set the bounds of the drawable and instead wrap the drawable in an instance of this class:
The text was updated successfully, but these errors were encountered: