| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.text; |
| 18 |
|
| 19 |
import android.annotation.ColorInt; |
| 20 |
import android.annotation.Px; |
| 21 |
import android.compat.annotation.UnsupportedAppUsage; |
| 22 |
import android.graphics.Paint; |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
public class TextPaint extends Paint { |
| 29 |
|
| 30 |
|
| 31 |
@ColorInt |
| 32 |
public int bgColor; |
| 33 |
public int baselineShift; |
| 34 |
@ColorInt |
| 35 |
public int linkColor; |
| 36 |
public int[] drawableState; |
| 37 |
public float density = 1.0f; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
@ColorInt |
| 42 |
public int underlineColor = 0; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
public @Px float underlineThickness; |
| 48 |
|
| 49 |
public TextPaint() { |
| 50 |
super(); |
| 51 |
} |
| 52 |
|
| 53 |
public TextPaint(int flags) { |
| 54 |
super(flags); |
| 55 |
} |
| 56 |
|
| 57 |
public TextPaint(Paint p) { |
| 58 |
super(p); |
| 59 |
} |
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public void set(TextPaint tp) { |
| 66 |
super.set(tp); |
| 67 |
|
| 68 |
bgColor = tp.bgColor; |
| 69 |
baselineShift = tp.baselineShift; |
| 70 |
linkColor = tp.linkColor; |
| 71 |
drawableState = tp.drawableState; |
| 72 |
density = tp.density; |
| 73 |
underlineColor = tp.underlineColor; |
| 74 |
underlineThickness = tp.underlineThickness; |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
@UnsupportedAppUsage |
| 84 |
public void setUnderlineText(int color, float thickness) { |
| 85 |
underlineColor = color; |
| 86 |
underlineThickness = thickness; |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
@Override |
| 93 |
public float getUnderlineThickness() { |
| 94 |
if (underlineColor != 0) { |
| 95 |
return underlineThickness; |
| 96 |
} else { |
| 97 |
return super.getUnderlineThickness(); |
| 98 |
} |
| 99 |
} |
| 100 |
} |