當前位置: 首頁>>代碼示例>>Java>>正文


Java Alignment.ALIGN_OPPOSITE屬性代碼示例

本文整理匯總了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;
  }
}
 
開發者ID:MLNO,項目名稱:airgram,代碼行數:16,代碼來源:WebvttCueParser.java

示例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;
	 }
 
開發者ID:gzncland,項目名稱:colorfullife,代碼行數:39,代碼來源:TextManager.java

示例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);
}
 
開發者ID:xieyangxuejun,項目名稱:CommentView,代碼行數:58,代碼來源:CanvasTextArea.java

示例4: getAlignment

@Override
public Alignment getAlignment() {
	return Alignment.ALIGN_OPPOSITE;
}
 
開發者ID:SysdataSpA,項目名稱:SDHtmlTextView,代碼行數:4,代碼來源:AlignOppositeSpan.java

示例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);
}
 
開發者ID:sanjaysingh1990,項目名稱:Exoplayer2Radio,代碼行數:79,代碼來源:Cea708Decoder.java


注:本文中的android.text.Layout.Alignment.ALIGN_OPPOSITE屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。