当前位置: 首页>>代码示例>>Java>>正文


Java DynamicDrawableSpan类代码示例

本文整理汇总了Java中android.text.style.DynamicDrawableSpan的典型用法代码示例。如果您正苦于以下问题:Java DynamicDrawableSpan类的具体用法?Java DynamicDrawableSpan怎么用?Java DynamicDrawableSpan使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DynamicDrawableSpan类属于android.text.style包,在下文中一共展示了DynamicDrawableSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private void init(AttributeSet attrs) {
    mEmojiconTextSize = (int) getTextSize();
    if (attrs == null) {
        mEmojiconSize = (int) getTextSize();
    } else {
        TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
        mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
        mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
        mTextStart = a.getInteger(R.styleable.Emojicon_emojiconTextStart, 0);
        mTextLength = a.getInteger(R.styleable.Emojicon_emojiconTextLength, -1);
        mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
        a.recycle();
    }
    addTextChangedListener(new EmojiTextWatcher(getContext(),mEmojiconSize,mEmojiconAlignment,mEmojiconTextSize,mUseSystemDefault));
    setText(getText());
}
 
开发者ID:nickyangjun,项目名称:EasyEmoji,代码行数:17,代码来源:EmojiconTextView.java

示例2: EmojiconSpan

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
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,代码行数:17,代码来源:EmojiconSpan.java

示例3: EmojixTextWatcher

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
public EmojixTextWatcher(TextView textView) {
    this.textView = textView;

    SpannableString s = new SpannableString(textView.getText());
    if (!TextUtils.isEmpty(s)) {
        float textSize = textView.getTextSize();

        EmojiconHandler.addEmojis(textView.getContext(), s, (int) textSize,
                DynamicDrawableSpan.ALIGN_BASELINE, (int) textSize, 0, -1);

        textView.setText(s, TextView.BufferType.EDITABLE);

        if (textView instanceof EditText) {
            EditText editText = (EditText) textView;
            editText.setSelection(s.length());
        }
    }
}
 
开发者ID:nekocode,项目名称:Emojix,代码行数:19,代码来源:EmojixTextWatcher.java

示例4: insertImage

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
/**
 * use local uri to insert a image
 *
 * @param uri image uri
 */
public void insertImage(Uri uri) {
    String path = UriUtils.getValidPath(getContext(), uri);
    Bitmap bitmap = bitmapCreator.getBitmapByDiskPath(path);

    SpannableString ss = new SpannableString(path);

    //construct a Drawable and set Bounds
    Drawable mDrawable = new BitmapDrawable(getContext().getResources(), bitmap);
    int width = mDrawable.getIntrinsicWidth();
    int height = mDrawable.getIntrinsicHeight();
    mDrawable.setBounds(0, 0, width > 0 ? width : 0, height > 0 ? height : 0);

    ImageSpan span = new ImageSpan(mDrawable, path, DynamicDrawableSpan.ALIGN_BOTTOM);
    ss.setSpan(span, 0, path.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    int start = this.getSelectionStart();

    getEditableText().insert(start, ss);//insert the imageSpan
    setSelection(start + ss.length());  //set selection start position
}
 
开发者ID:nebulae-pan,项目名称:RichEditText,代码行数:26,代码来源:RichEditText.java

示例5: init

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private void init(Context context, AttributeSet attrs) {
    if (isInEditMode())
        return;

    if (attrs != null) {
        TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.RichTextView);
        needNumberShow = array.getBoolean(R.styleable.RichTextView_needNumberShow, false);
        needUrlShow = array.getBoolean(R.styleable.RichTextView_needUrlShow, false);
        atColor = array.getColor(R.styleable.RichTextView_atColor, Color.BLUE);
        topicColor = array.getColor(R.styleable.RichTextView_topicColor, Color.BLUE);
        linkColor = array.getColor(R.styleable.RichTextView_linkColor, Color.BLUE);
        emojiSize = array.getInteger(R.styleable.RichTextView_emojiSize, 0);
        emojiVerticalAlignment = array.getInteger(R.styleable.RichTextView_emojiVerticalAlignment, DynamicDrawableSpan.ALIGN_BOTTOM);
        array.recycle();
    }
}
 
开发者ID:CarGuo,项目名称:RickText,代码行数:17,代码来源:RichTextView.java

示例6: draw

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
@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,代码行数:20,代码来源:CenteredImageSpan.java

示例7: release

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
public void release() {
    mText = null;
    mReleased = true;
    if (lines != null)
        lines.clear();
    lineSpan = null;
    chars = null;
    for (int i = 0; i < mDynamicDrawableSpanSparseArray.size(); i++) {
        int key = mDynamicDrawableSpanSparseArray.keyAt(i);
        DynamicDrawableSpan span = mDynamicDrawableSpanSparseArray.get(key);
        Drawable dr = span.getDrawable();
        if (dr != null && dr instanceof LazyDrawable) {
            ((LazyDrawable) dr).Unload();
        }
    }
    mDynamicDrawableSpanSparseArray.clear();
}
 
开发者ID:suwhs,项目名称:wATLlib,代码行数:18,代码来源:TextLayout.java

示例8: onBindFlexibleViewHolder

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
@Override
public void onBindFlexibleViewHolder(SideFilterViewHolder holder,
		int position) {
	SideFilterInfo item = getItem(position);
	if (item.letters.equals(FilterConstants.LETTERS_BS)) {
		Drawable drawableCompat = AndroidUtilsUI.getDrawableWithBounds(context,
				R.drawable.ic_backspace_white_24dp);
		ImageSpan imageSpan = new ImageSpan(drawableCompat,
				DynamicDrawableSpan.ALIGN_BOTTOM);
		SpannableStringBuilder ss = new SpannableStringBuilder(",");
		ss.setSpan(imageSpan, 0, 1, 0);
		holder.tvText.setText(ss);
	} else {
		holder.tvText.setText(item.letters);

		int resID = item.letters.length() > 1
				? android.R.style.TextAppearance_Small
				: android.R.style.TextAppearance_Large;
		holder.tvText.setTextAppearance(context, resID);
		holder.tvText.setTextColor(
				ContextCompat.getColor(context, R.color.login_text_color));
	}
	if (holder.tvCount != null) {
		holder.tvCount.setText(item.count > 0 ? String.valueOf(item.count) : "");
	}
}
 
开发者ID:vuze,项目名称:vuze-remote-for-android,代码行数:27,代码来源:SideFilterAdapter.java

示例9: getDynamicImageSpan

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private DynamicDrawableSpan getDynamicImageSpan(String content) {
	String idStr = EmojiUtil.getInstance().getFaceId(content);
	Resources resources = getContext().getResources();
	int id = resources.getIdentifier(EmojiUtil.DYNAMIC_FACE_PREFIX + idStr,
			"drawable", getContext().getPackageName());
	if (id > 0) {
		try {
			AnimatedImageSpan imageSpan = new AnimatedImageSpan(
					new AnimatedGifDrawable(getResources(),
							Math.round(getTextSize()) + 10, getResources()
									.openRawResource(id),
							new AnimatedGifDrawable.UpdateListener() {
								@Override
								public void update() {
									// update the textview
									EmojiTextView.this.postInvalidate();
								}
							}));
			return imageSpan;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return null;
}
 
开发者ID:victoryckl,项目名称:XmppTest,代码行数:26,代码来源:EmojiTextView.java

示例10: getDynamicImageSpan

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private DynamicDrawableSpan getDynamicImageSpan(String content) {
	String idStr = EmojiUtil.getInstance().getFaceId(content);
	Resources resources = getContext().getResources();
	int id = resources.getIdentifier(
			EmojiUtil.DYNAMIC_FACE_PREFIX + idStr, "drawable",
			getContext().getPackageName());
	if (id > 0) {
		try {
			AnimatedImageSpan imageSpan = new AnimatedImageSpan(
					new AnimatedGifDrawable(getResources(),
							Math.round(getTextSize()) + 10, getResources()
									.openRawResource(id), null));
			return imageSpan;
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	return null;
}
 
开发者ID:victoryckl,项目名称:XmppTest,代码行数:20,代码来源:EmojiEditText.java

示例11: normalizeAlignment

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
/**
 * 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,代码行数:17,代码来源:BetterImageSpan.java

示例12: init

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
    mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
    mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
    a.recycle();
    mEmojiconTextSize = (int) getTextSize();
    addTextChangedListener(new EmojiTextWatcher(getContext(),mEmojiconSize,mEmojiconAlignment,mEmojiconTextSize,mUseSystemDefault));
    setText(getText());
}
 
开发者ID:nickyangjun,项目名称:EasyEmoji,代码行数:11,代码来源:EmojiconEditText.java

示例13: init

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private void init(AttributeSet attrs) {
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.Emojicon);
    mEmojiconSize = (int) a.getDimension(R.styleable.Emojicon_emojiconSize, getTextSize());
    mEmojiconAlignment = a.getInt(R.styleable.Emojicon_emojiconAlignment, DynamicDrawableSpan.ALIGN_BASELINE);
    mUseSystemDefault = a.getBoolean(R.styleable.Emojicon_emojiconUseSystemDefault, false);
    a.recycle();
    mEmojiconTextSize = (int) getTextSize();
    setText(getText());
}
 
开发者ID:nickyangjun,项目名称:EasyEmoji,代码行数:10,代码来源:EmojiconMultiAutoCompleteTextView.java

示例14: setImageSpan

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private SpannableString setImageSpan(){
    String text = "  ";
    SpannableString imgSpanText = new SpannableString(text);
    imgSpanText.setSpan(new ImageSpan(AppApplication.getAppContext(), R.drawable.dianzansmal, DynamicDrawableSpan.ALIGN_BASELINE),
            0 , 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    return imgSpanText;
}
 
开发者ID:wp521,项目名称:MyFire,代码行数:8,代码来源:FavortListAdapter.java

示例15: setImageSpan

import android.text.style.DynamicDrawableSpan; //导入依赖的package包/类
private SpannableString setImageSpan(List<String> list) {
        SpannableString spannableString = new SpannableString("..");
        if (list != null && list.contains(UserManager.getInstance().getCurrentUser().getObjectId())) {
                spannableString.setSpan(new ImageSpan(getContext(), R.drawable.ic_favorite_deep_orange_a700_24dp, DynamicDrawableSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        } else {
                spannableString.setSpan(new ImageSpan(getContext(), R.drawable.ic_favorite_border_deep_orange_a700_24dp, DynamicDrawableSpan.ALIGN_BASELINE), 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        }
        return spannableString;
}
 
开发者ID:HelloChenJinJun,项目名称:TestChat,代码行数:10,代码来源:LikerTextView.java


注:本文中的android.text.style.DynamicDrawableSpan类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。