import android.view.View;
import net.ktnx.mobileledger.utils.Colors;
+import net.ktnx.mobileledger.utils.DimensionUtils;
import androidx.annotation.Nullable;
setInitialHue(initialHueDegrees);
setHue(initialHueDegrees);
+
+ padding = DimensionUtils.dp2px(getContext(), 4);
}
public int getColor() {
return color;
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
+ float center = getWidth() / 2f;
ringPaint.setStrokeWidth((int) bandWidth);
- canvas.translate(centerX, centerY);
+ canvas.translate(center, center);
canvas.drawOval(ringRect, ringPaint);
canvas.drawArc(centerRect, 180, 180, true, initialPaint);
int heightMode = View.MeasureSpec.getMode(heightMeasureSpec);
int heightSize = View.MeasureSpec.getSize(heightMeasureSpec);
- if (((widthMode == MeasureSpec.AT_MOST) && (heightMode == MeasureSpec.AT_MOST)) ||
- ((widthMode == MeasureSpec.EXACTLY) && (heightMode == MeasureSpec.EXACTLY)))
- {
+ if ((widthMode == MeasureSpec.AT_MOST) && (heightMode == MeasureSpec.AT_MOST)) {
diameter = Math.min(widthSize, heightSize);
}
+ else {
+ setMeasuredDimension(MEASURED_STATE_TOO_SMALL, MEASURED_STATE_TOO_SMALL);
+ return;
+ }
setMeasuredDimension(diameter, diameter);
// padding = DimensionUtils.dp2px(getContext(),
// getContext().getResources().getDimension(R.dimen.activity_horizontal_margin)) / 2;
- padding = 0;
diameter -= 2 * padding;
radius = diameter / 2f;
centerX = padding + (int) radius;
<net.ktnx.mobileledger.ui.HueRing
android:id="@+id/ring"
- android:layout_width="match_parent"
+ android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@id/button_pane"
app:layout_constraintEnd_toEndOf="parent"