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


Java DynamicDrawableSpan.ALIGN_BOTTOM属性代码示例

本文整理汇总了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
}
 
开发者ID:nebulae-pan,项目名称:RichEditText,代码行数:25,代码来源:RichEditText.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: 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) : "");
	}
}
 
开发者ID:vuze,项目名称:vuze-remote-for-android,代码行数:26,代码来源:SideFilterAdapter.java

示例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;
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:BetterImageSpan.java

示例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;
}
 
开发者ID:Mark-Lauman,项目名称:DominionPicker,代码行数:30,代码来源:ImageLibrary.java

示例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;
}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:8,代码来源:RecipientChip.java

示例7: CenteredImageSpan

public CenteredImageSpan(final Drawable drawable) {
    this(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
}
 
开发者ID:Fueled,项目名称:snippety,代码行数:3,代码来源:CenteredImageSpan.java

示例8: VisibleRecipientChip

public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
    this(drawable, entry, DynamicDrawableSpan.ALIGN_BOTTOM);
}
 
开发者ID:jianliaoim,项目名称:talk-android,代码行数:3,代码来源:VisibleRecipientChip.java

示例9: EmojiSpan

public EmojiSpan(EmojiDrawable d) {
    super(d, DynamicDrawableSpan.ALIGN_BOTTOM);
}
 
开发者ID:tonilopezmr,项目名称:Game-of-Thrones,代码行数:3,代码来源:Emoji.java

示例10: DrawableChip

public DrawableChip(final Drawable drawable, BaseChip chip) {
	super(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);
	mDelegate = chip;
}
 
开发者ID:pecheur,项目名称:android-chip-edittextview,代码行数:4,代码来源:DrawableChip.java

示例11: MoreImageSpan

public MoreImageSpan(Drawable b) {
    super(b, DynamicDrawableSpan.ALIGN_BOTTOM);
}
 
开发者ID:pecheur,项目名称:android-chip-edittextview,代码行数:3,代码来源:ChipEditTextView.java

示例12: VisibleRecipientChip

public VisibleRecipientChip(final Drawable drawable, final RecipientEntry entry) {
    super(drawable, DynamicDrawableSpan.ALIGN_BOTTOM);

    mDelegate = new SimpleRecipientChip(entry);
}
 
开发者ID:AndroidDeveloperLB,项目名称:ChipsLibrary,代码行数:5,代码来源:VisibleRecipientChip.java

示例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;

}
 
开发者ID:appwoodoo,项目名称:appwoodoo-android-sdk,代码行数:44,代码来源:MainActivity.java


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