mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Compute padding/margins more precisely on CheckmarkView
This commit is contained in:
@@ -30,6 +30,7 @@ import android.text.Layout;
|
|||||||
import android.text.StaticLayout;
|
import android.text.StaticLayout;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import org.isoron.uhabits.R;
|
import org.isoron.uhabits.R;
|
||||||
@@ -48,9 +49,9 @@ public class CheckmarkView extends View
|
|||||||
|
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
private int leftMargin;
|
private float leftMargin;
|
||||||
private int topMargin;
|
private float topMargin;
|
||||||
private int padding;
|
private float padding;
|
||||||
private String label;
|
private String label;
|
||||||
|
|
||||||
private String fa_check;
|
private String fa_check;
|
||||||
@@ -150,8 +151,6 @@ public class CheckmarkView extends View
|
|||||||
pIcon.setTextSize(width * 0.5f);
|
pIcon.setTextSize(width * 0.5f);
|
||||||
pIcon.getTextBounds(text, 0, 1, rect);
|
pIcon.getTextBounds(text, 0, 1, rect);
|
||||||
|
|
||||||
// canvas.drawLine(0, 0.67f * height, width, 0.67f * height, pIcon);
|
|
||||||
|
|
||||||
int y = (int) ((0.67f * height - rect.bottom - rect.top) / 2);
|
int y = (int) ((0.67f * height - rect.bottom - rect.top) / 2);
|
||||||
canvas.drawText(text, width / 2, y, pIcon);
|
canvas.drawText(text, width / 2, y, pIcon);
|
||||||
}
|
}
|
||||||
@@ -186,8 +185,8 @@ public class CheckmarkView extends View
|
|||||||
this.width = getMeasuredWidth();
|
this.width = getMeasuredWidth();
|
||||||
this.height = getMeasuredHeight();
|
this.height = getMeasuredHeight();
|
||||||
|
|
||||||
leftMargin = (int) (width * 0.015);
|
leftMargin = (width * 0.015f);
|
||||||
topMargin = (int) (height * 0.015);
|
topMargin = (height * 0.015f);
|
||||||
padding = 8 * leftMargin;
|
padding = 8 * leftMargin;
|
||||||
textPaint.setTextSize(0.15f * width);
|
textPaint.setTextSize(0.15f * width);
|
||||||
|
|
||||||
@@ -203,7 +202,8 @@ public class CheckmarkView extends View
|
|||||||
this.label = habit.name;
|
this.label = habit.name;
|
||||||
|
|
||||||
textPaint.setColor(Color.WHITE);
|
textPaint.setColor(Color.WHITE);
|
||||||
labelLayout = new StaticLayout(label, textPaint, width - 2 * leftMargin - 2 * padding,
|
labelLayout = new StaticLayout(label, textPaint,
|
||||||
|
(int) (width - 2 * leftMargin - 2 * padding),
|
||||||
Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
Layout.Alignment.ALIGN_CENTER, 1.0f, 0.0f, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user