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


Java DynamicDrawableSpan.ALIGN_BASELINE屬性代碼示例

本文整理匯總了Java中android.text.style.DynamicDrawableSpan.ALIGN_BASELINE屬性的典型用法代碼示例。如果您正苦於以下問題:Java DynamicDrawableSpan.ALIGN_BASELINE屬性的具體用法?Java DynamicDrawableSpan.ALIGN_BASELINE怎麽用?Java DynamicDrawableSpan.ALIGN_BASELINE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.text.style.DynamicDrawableSpan的用法示例。


在下文中一共展示了DynamicDrawableSpan.ALIGN_BASELINE屬性的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: EmojiconSpan

public EmojiconSpan(Context context, Drawable drawable,
		int textSize) {
	super(DynamicDrawableSpan.ALIGN_BASELINE);
	mContext = context;
	mDrawable = drawable;
	mWidth = mHeight = mSize = 2 * textSize;
	mTextSize = textSize;

	if (mDrawable != null) {
		mHeight = mSize;
		mWidth = mHeight * mDrawable.getIntrinsicWidth()
				/ mDrawable.getIntrinsicHeight();
		mTop = (mTextSize - mHeight) / 2;
		mDrawable.setBounds(0, mTop, mWidth, mTop + mHeight);
	}
}
 
開發者ID:lennyup,項目名稱:react-native-udesk,代碼行數:16,代碼來源:EmojiconSpan.java

示例2: draw

@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom,
                 Paint paint) {

    if (mVerticalAlignment == DynamicDrawableSpan.ALIGN_BASELINE || mVerticalAlignment == DynamicDrawableSpan.ALIGN_BOTTOM) {
        super.draw(canvas, text, start, end, x, top, y, bottom, paint);
        return;
    }

    Drawable b = getDrawable();
    canvas.save();
    int transY = 0;
    //獲得將要顯示的文本高度-圖片高度除2等居中位置+top(換行情況)
    transY = ((bottom - top) - b.getBounds().bottom) / 2 + top;
    //偏移畫布後開始繪製
    canvas.translate(x, transY);
    b.draw(canvas);
    canvas.restore();
}
 
開發者ID:CarGuo,項目名稱:RickText,代碼行數:19,代碼來源:CenteredImageSpan.java

示例3: normalizeAlignment

/**
 * A helper function to allow dropping in BetterImageSpan as a replacement to ImageSpan,
 * and allowing for center alignment if passed in.
 */
public static final @BetterImageSpanAlignment
int normalizeAlignment(int alignment) {
  switch (alignment) {
    case DynamicDrawableSpan.ALIGN_BOTTOM:
      return ALIGN_BOTTOM;
    case ALIGN_CENTER:
      return ALIGN_CENTER;
    case DynamicDrawableSpan.ALIGN_BASELINE:
    default:
      return ALIGN_BASELINE;
  }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:BetterImageSpan.java

示例4: EmojiconSpan

public EmojiconSpan(Context context, int resourceId, int size, int textSize) {
    super(DynamicDrawableSpan.ALIGN_BASELINE);
    mContext = context;
    mResourceId = resourceId;
    mWidth = mHeight = mSize = size;
    mTextSize = textSize;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:7,代碼來源:EmojiconSpan.java

示例5: ChatAdapter

public ChatAdapter(ChatRecyclerView aRecyclerView, Activity aContext, ChatAdapterCallback aCallback) {
	messages = new ArrayList<>();
	mRecyclerView = aRecyclerView;
	context = aContext;
	mCallback = aCallback;
	settings = new Settings(context);
	linkPattern = Pattern.compile("((http|https|ftp)\\:\\/\\/[a-zA-Z0-9\\-\\.]+\\.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?\\/?([a-zA-Z0\u200C123456789\\-\\._\\?\\,\\'\\/\\\\\\+&amp;%\\$#\\=~])*[^\\.\\,\\)\\(\\s])");

	emoteAlignment = DynamicDrawableSpan.ALIGN_BASELINE;
	imageMod = new ImageSpan(context, R.drawable.ic_moderator, emoteAlignment);
	imageTurbo = new ImageSpan(context, R.drawable.ic_twitch_turbo, emoteAlignment);
	isNightTheme = settings.getTheme().equals(context.getString(R.string.night_theme_name)) || settings.getTheme().equals(context.getString(R.string.true_night_theme_name));
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:13,代碼來源:ChatAdapter.java

示例6: EmojiSpan

public EmojiSpan(Context context, int resourceId, int size, int textSize) {
    super(DynamicDrawableSpan.ALIGN_BASELINE);
    mContext = context;
    mResourceId = resourceId;
    mWidth = mHeight = mSize = size;
    mTextSize = textSize;
}
 
開發者ID:umeng,項目名稱:umeng_community_android,代碼行數:7,代碼來源:EmojiSpan.java

示例7: setSpanBubbles

/**
 * Outputs span bubbles to ss based on text wrapped in token
 */
public static void setSpanBubbles(final SpannableStringBuilder ss,
	String text,
	String token, final TextPaint p, final int borderColor,
	final int textColor, final int fillColor,
	@Nullable final SpanBubbleListener listener) {
	if (ss.length() > 0) {
		// hack so ensure descent is always added by TextView
		ss.append("\u200B");
	}

	// Start and end refer to the points where the span will apply
	int tokenLen = token.length();
	int base = 0;

	int index = 0;
	while (true) {
		int start = text.indexOf(token, base);
		int end = text.indexOf(token, start + tokenLen);

		if (start < 0 || end < 0) {
			break;
		}

		base = end + tokenLen;

		final String word = text.substring(start + tokenLen, end);

		final int finalIndex = index;
		Drawable imgDrawable = new MyDrawable(finalIndex, word, p, fillColor,
				borderColor, textColor, listener);

		float w = p.measureText(word + "__");
		float bottom = -p.ascent() + p.descent();
		int y = 0;

		imgDrawable.setBounds(0, y, (int) w, (int) (bottom + p.descent()));

		ImageSpan imageSpan = new ImageSpan(imgDrawable,
				DynamicDrawableSpan.ALIGN_BASELINE);

		ss.setSpan(imageSpan, start, end + tokenLen, 0);

		if (listener != null) {
			ClickableSpan clickSpan = new ClickableSpan() {

				@Override
				public void onClick(View widget) {
					listener.spanBubbleClicked(finalIndex, word);

					if (AndroidUtils.hasTouchScreen()) {
						Selection.removeSelection(ss);
					}
					widget.invalidate();
				}
			};
			ss.setSpan(clickSpan, start, end + tokenLen, 0);
		}

		index++;
	}
}
 
開發者ID:vuze,項目名稱:vuze-remote-for-android,代碼行數:64,代碼來源:SpanBubbles.java


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