当前位置: 首页>>代码示例>>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;未经允许,请勿转载。