本文整理汇总了Java中android.text.Layout.Alignment.ALIGN_OPPOSITE属性的典型用法代码示例。如果您正苦于以下问题:Java Alignment.ALIGN_OPPOSITE属性的具体用法?Java Alignment.ALIGN_OPPOSITE怎么用?Java Alignment.ALIGN_OPPOSITE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.Layout.Alignment
的用法示例。
在下文中一共展示了Alignment.ALIGN_OPPOSITE属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseTextAlignment
private static Alignment parseTextAlignment(String s) {
switch (s) {
case "start":
case "left":
return Alignment.ALIGN_NORMAL;
case "center":
case "middle":
return Alignment.ALIGN_CENTER;
case "end":
case "right":
return Alignment.ALIGN_OPPOSITE;
default:
Log.w(TAG, "Invalid alignment value: " + s);
return null;
}
}
示例2: createBitmap
private static Bitmap createBitmap(String setString,int setWidth,int setHeight,Alignment setAlign, int setSize, boolean setBold,int setColor){
Bitmap bitmap = Bitmap.createBitmap(setWidth,setHeight, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
TextPaint paint = new TextPaint();
paint.setColor(setColor);
paint.setSubpixelText(true);
paint.setAntiAlias(true);
//paint.setTextAlign(setAlign);
//paint.setFakeBoldText(setBold);
if(setBold){
//paint.setTypeface( Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
paint.setStrokeWidth(1.5f);
paint.setStyle(Style.FILL_AND_STROKE);
}
paint.setTextSize(setSize);
StaticLayout layout = new StaticLayout(setString,paint,setWidth,setAlign,1f,2,false);
if(setAlign == Alignment.ALIGN_OPPOSITE){
canvas.translate(-2,2);
}else {
canvas.translate(2,5);
}
layout.draw(canvas);
// if(setAlign == Align.RIGHT){
// canvas.drawText(setString, setWidth, setHeight, paint);
// }else{
// canvas.drawText(setString, 0, setHeight, paint);
// }
return bitmap;
}
示例3: CanvasTextArea
public CanvasTextArea(CanvasHost canvasHost, LayoutAttrSet layoutAttrSet) {
super(canvasHost, layoutAttrSet);
this.mPaint.density = canvasHost.getContext().getResources().getDisplayMetrics().density;
if (layoutAttrSet != null) {
if (layoutAttrSet.getAttr(TextColor, null) != null) {
String attr = layoutAttrSet.getAttr(TextColor, null);
if (!TextUtils.isEmpty(attr)) {
try {
setTextColor(Color.parseColor(attr));
} catch (Exception e) {
}
}
}
if (layoutAttrSet.hasAttr(TextSize)) {
setTextSize((float) layoutAttrSet.getAttr(TextSize, 15));
}
if (layoutAttrSet.hasAttr(MaxLine)) {
setMaxLines(layoutAttrSet.getAttr(MaxLine, Integer.MAX_VALUE));
}
if (layoutAttrSet.getAttr("text", null) != null) {
CharSequence attr2 = layoutAttrSet.getAttr("text", null);
if (!TextUtils.isEmpty(attr2)) {
setText(attr2);
}
}
String str = "ALIGN_NORMAL";
if (layoutAttrSet.hasAttr(TextAlignment)) {
str = layoutAttrSet.getAttr(TextAlignment, "ALIGN_NORMAL");
}
boolean z = true;
switch (str.hashCode()) {
case -1371700497:
if (str.equals("ALIGN_CENTER")) {
z = true;
this.mLayoutAlignment = Alignment.ALIGN_CENTER;
break;
}
break;
case -1047432319:
if (str.equals("ALIGN_NORMAL")) {
z = false;
this.mLayoutAlignment = Alignment.ALIGN_NORMAL;
break;
}
break;
case 1015327489:
if (str.equals("ALIGN_OPPOSITE")) {
z = true;
this.mLayoutAlignment = Alignment.ALIGN_OPPOSITE;
break;
}
break;
default:
throw new RuntimeException("Text alignment\"" + str + "\" is not supported");
}
}
setEllipsize(TextUtils.TruncateAt.END);
}
示例4: getAlignment
@Override
public Alignment getAlignment() {
return Alignment.ALIGN_OPPOSITE;
}
示例5: build
public Cea708Cue build() {
if (isEmpty()) {
// The cue is empty.
return null;
}
SpannableStringBuilder cueString = new SpannableStringBuilder();
// Add any rolled up captions, separated by new lines.
for (int i = 0; i < rolledUpCaptions.size(); i++) {
cueString.append(rolledUpCaptions.get(i));
cueString.append('\n');
}
// Add the current line.
cueString.append(buildSpannableString());
// TODO: Add support for right-to-left languages (i.e. where right would correspond to normal
// alignment).
Alignment alignment;
switch (justification) {
case JUSTIFICATION_FULL:
// TODO: Add support for full justification.
case JUSTIFICATION_LEFT:
alignment = Alignment.ALIGN_NORMAL;
break;
case JUSTIFICATION_RIGHT:
alignment = Alignment.ALIGN_OPPOSITE;
break;
case JUSTIFICATION_CENTER:
alignment = Alignment.ALIGN_CENTER;
break;
default:
throw new IllegalArgumentException("Unexpected justification value: " + justification);
}
float position;
float line;
if (relativePositioning) {
position = (float) horizontalAnchor / RELATIVE_CUE_SIZE;
line = (float) verticalAnchor / RELATIVE_CUE_SIZE;
} else {
position = (float) horizontalAnchor / HORIZONTAL_SIZE;
line = (float) verticalAnchor / VERTICAL_SIZE;
}
// Apply screen-edge padding to the line and position.
position = (position * 0.9f) + 0.05f;
line = (line * 0.9f) + 0.05f;
// anchorId specifies where the anchor should be placed on the caption cue/window. The 9
// possible configurations are as follows:
// 0-----1-----2
// | |
// 3 4 5
// | |
// 6-----7-----8
@AnchorType int verticalAnchorType;
if (anchorId % 3 == 0) {
verticalAnchorType = Cue.ANCHOR_TYPE_START;
} else if (anchorId % 3 == 1) {
verticalAnchorType = Cue.ANCHOR_TYPE_MIDDLE;
} else {
verticalAnchorType = Cue.ANCHOR_TYPE_END;
}
// TODO: Add support for right-to-left languages (i.e. where start is on the right).
@AnchorType int horizontalAnchorType;
if (anchorId / 3 == 0) {
horizontalAnchorType = Cue.ANCHOR_TYPE_START;
} else if (anchorId / 3 == 1) {
horizontalAnchorType = Cue.ANCHOR_TYPE_MIDDLE;
} else {
horizontalAnchorType = Cue.ANCHOR_TYPE_END;
}
boolean windowColorSet = (windowFillColor != COLOR_SOLID_BLACK);
return new Cea708Cue(cueString, alignment, line, Cue.LINE_TYPE_FRACTION, verticalAnchorType,
position, horizontalAnchorType, Cue.DIMEN_UNSET, windowColorSet, windowFillColor,
priority);
}