本文整理汇总了Java中android.text.style.DynamicDrawableSpan.ALIGN_BOTTOM属性的典型用法代码示例。如果您正苦于以下问题:Java DynamicDrawableSpan.ALIGN_BOTTOM属性的具体用法?Java DynamicDrawableSpan.ALIGN_BOTTOM怎么用?Java DynamicDrawableSpan.ALIGN_BOTTOM使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.style.DynamicDrawableSpan
的用法示例。
在下文中一共展示了DynamicDrawableSpan.ALIGN_BOTTOM属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertImage
/**
* 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
}
示例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();
}
示例3: onBindFlexibleViewHolder
@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) : "");
}
}
示例4: 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;
}
}
示例5: getSpan
/** Get an ImageSpan based off the drawable with the given value and size.
* @param id A unique id value will receive a unique ImageSpan instance.
* @return An ImageSpan for the given size and value.
* {@code null} if the drawable for this value and size has not been set yet. */
public synchronized ImageSpan getSpan(CharSequence value, int size, int id) {
// Get the available sizes for the given value
HashMap<Integer, HashMap<Integer, ImageSpan>> sizes = spans.get(value);
if(sizes == null) {
sizes = new HashMap<>(1);
spans.put(value, sizes);
}
// Get the available instances for the given size
HashMap<Integer, ImageSpan> instances = sizes.get(size);
if(instances == null) {
instances = new HashMap<>(1);
sizes.put(size, instances);
}
// Return the ImageSpan with this id
ImageSpan res = instances.get(id);
if(res != null) return res;
// We have no ImageSpan with that id. So lets try to make one
Drawable d = getDrawable(value, size);
if(d == null) return null;
res = new ImageSpan(d, DynamicDrawableSpan.ALIGN_BOTTOM);
instances.put(id, res);
return res;
}
示例6: RecipientChip
public RecipientChip(Drawable drawable, RecipientEntry entry, int offset) {
super(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
mDisplay = entry.getDisplayName();
mValue = entry.getDestination().trim();
mContactId = entry.getContactId();
mDataId = entry.getDataId();
mEntry = entry;
}
示例7: CenteredImageSpan
public CenteredImageSpan(final Drawable drawable) {
this(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
}
示例8: VisibleRecipientChip
public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
this(drawable, entry, DynamicDrawableSpan.ALIGN_BOTTOM);
}
示例9: EmojiSpan
public EmojiSpan(EmojiDrawable d) {
super(d, DynamicDrawableSpan.ALIGN_BOTTOM);
}
示例10: DrawableChip
public DrawableChip(final Drawable drawable, BaseChip chip) {
super(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
mDelegate = chip;
}
示例11: MoreImageSpan
public MoreImageSpan(Drawable b) {
super(b, DynamicDrawableSpan.ALIGN_BOTTOM);
}
示例12: VisibleRecipientChip
public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
super(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
mDelegate = new SimpleRecipientChip(entry);
}
示例13: getPageTitle
@Override
public CharSequence getPageTitle(int position) {
String text = "";
Drawable drawable;
switch (position) {
case 0:
text = getString(R.string.tabs_home);
drawable = getResources().getDrawable(R.drawable.ic_tab_woodoo);
break;
case 1:
text = Woodoo.stories().getStoryWall(getApplicationContext()).getTitle();
if (text == null) {
text = getString(R.string.tabs_home);
}
drawable = getResources().getDrawable(R.drawable.ic_tab_stories);
break;
case 2:
text = getString(R.string.tabs_dialogs);
drawable = getResources().getDrawable(R.drawable.ic_tab_dialogs);
break;
case 3:
text = getString(R.string.tabs_remoteconfig);
drawable = getResources().getDrawable(R.drawable.ic_tab_remoteconfig);
break;
case 4:
text = getString(R.string.tabs_yoursettings);
drawable = getResources().getDrawable(R.drawable.ic_tab_settings);
break;
default:
drawable = getResources().getDrawable(R.drawable.ic_tab_woodoo);
text = "";
}
SpannableStringBuilder sb = new SpannableStringBuilder(" " + text);
drawable.setBounds(32, 32, 82, 82);
ImageSpan span = new ImageSpan(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
sb.setSpan(span, 0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
return sb;
}