Add high-contrast shadow to the main text in DirectionDragButton
This commit is contained in:
parent
68cded37d9
commit
a3c6d21a52
@ -90,5 +90,6 @@ public class DirectionDragButton extends DragButton implements DirectionDragView
|
||||
@Override
|
||||
public void setHighContrast(boolean highContrast) {
|
||||
textView.setHighContrast(highContrast);
|
||||
PaintCache.setHighContrast(getPaint(), highContrast, getTextColors().getDefaultColor());
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import android.graphics.Canvas;
|
||||
import android.graphics.Typeface;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextPaint;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
|
@ -191,11 +191,15 @@ class PaintCache {
|
||||
paint.setTypeface(spec.typeface);
|
||||
}
|
||||
paint.setTextSize(spec.textSize);
|
||||
if (spec.highContrast && spec.needsShadow()) {
|
||||
paint.setShadowLayer(shadowRadius, 0, 0, BLACK);
|
||||
} else {
|
||||
paint.setShadowLayer(0, 0, 0, BLACK);
|
||||
}
|
||||
setHighContrast(paint, spec.highContrast, spec.color);
|
||||
return paint;
|
||||
}
|
||||
|
||||
public static void setHighContrast(@NonNull Paint paint, boolean highContrast, @ColorInt int color) {
|
||||
if (highContrast && Spec.needsShadow(color)) {
|
||||
paint.setShadowLayer(get().shadowRadius, 0, 0, BLACK);
|
||||
} else {
|
||||
paint.clearShadowLayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user