not centered text in button
This commit is contained in:
parent
183e1a9a3b
commit
0b0d07be86
@ -11,6 +11,7 @@
|
||||
a:text="@string/c_history_button"
|
||||
calc:textUp="@string/c_undo"
|
||||
calc:textDown="@string/c_redo"
|
||||
calc:hTextPosition="0.33"
|
||||
style="?controlButtonStyle"
|
||||
a:textStyle="bold"
|
||||
a:onClick="historyButtonClickHandler"/>
|
@ -4,6 +4,7 @@
|
||||
<attr name="textUp" format="string"/>
|
||||
<attr name="textDown" format="string"/>
|
||||
<attr name="directionTextScale" format="float"/>
|
||||
<attr name="hTextPosition" format="float"/>
|
||||
</declare-styleable>
|
||||
|
||||
<declare-styleable name="NumberRangeSeekBar">
|
||||
|
@ -59,6 +59,9 @@ public class ColorButton extends Button {
|
||||
@NotNull
|
||||
private final OnClickListenerVibrator onClickListener;
|
||||
|
||||
private static final float H_TEXT_POSITION_DEFAULT_VALUE = 0.5f;
|
||||
private float hTextPosition = H_TEXT_POSITION_DEFAULT_VALUE;
|
||||
|
||||
public ColorButton(Context context, AttributeSet attrs) {
|
||||
this(context, attrs, true);
|
||||
}
|
||||
@ -106,7 +109,7 @@ public class ColorButton extends Button {
|
||||
private Point2d getTextPosition(@NotNull Paint paint, @NotNull CharSequence text) {
|
||||
final Point2d result = new Point2d();
|
||||
|
||||
result.setX((getWidth() - paint.measureText(text.toString())) / 2);
|
||||
result.setX(hTextPosition * getWidth() - 0.5f * paint.measureText(text.toString()));
|
||||
|
||||
float height = getHeight() - paint.ascent() - paint.descent();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user