本文整理汇总了Java中android.text.TextUtils.TruncateAt.END属性的典型用法代码示例。如果您正苦于以下问题:Java TruncateAt.END属性的具体用法?Java TruncateAt.END怎么用?Java TruncateAt.END使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.text.TextUtils.TruncateAt
的用法示例。
在下文中一共展示了TruncateAt.END属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMeasure
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int size = MeasureSpec.getSize(widthMeasureSpec);
final int mode = MeasureSpec.getMode(widthMeasureSpec);
if (!useSystemEmoji() &&
getEllipsize() == TruncateAt.END &&
!TextUtils.isEmpty(source) &&
(mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) &&
getPaint().breakText(source, 0, source.length()-1, true, size, null) != source.length())
{
needsEllipsizing = true;
FontMetricsInt font = getPaint().getFontMetricsInt();
super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(Math.abs(font.top - font.bottom), MeasureSpec.EXACTLY));
} else {
needsEllipsizing = false;
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
示例2: filter
@Override public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend)
{
char[] v = new char[end - start];
TextUtils.getChars(source, start, end, v, 0);
Spannable emojified = EmojiProvider.getInstance(view.getContext()).emojify(new String(v), view);
if (source instanceof Spanned) {
TextUtils.copySpansFrom((Spanned) source, start, end, null, emojified, 0);
}
view.getViewTreeObserver().addOnGlobalLayoutListener(this);
if (view.getWidth() == 0 || view.getEllipsize() != TruncateAt.END) {
return emojified;
} else {
return TextUtils.ellipsize(emojified,
view.getPaint(),
view.getWidth() - view.getPaddingRight() - view.getPaddingLeft(),
TruncateAt.END);
}
}
示例3: ellipsize
public static CharSequence ellipsize(@Nullable CharSequence text, @NonNull TextView view) {
if (TextUtils.isEmpty(text) || view.getWidth() == 0 || view.getEllipsize() != TruncateAt.END) {
return text;
} else {
return TextUtils.ellipsize(text,
view.getPaint(),
view.getWidth() - view.getPaddingRight() - view.getPaddingLeft(),
TruncateAt.END);
}
}
示例4: parseEllipsize
/**
* Returns the value of the enum {@link TruncateAt}, which corresponds to a specific value.
*
* @param value
* The value
* @return The value of the enum {@link TruncateAt}, which corresponds to the given value
*/
private TruncateAt parseEllipsize(final int value) {
switch (value) {
case ELLIPSIZE_START_VALUE:
return TruncateAt.START;
case ELLIPSIZE_MIDDLE_VALUE:
return TruncateAt.MIDDLE;
case ELLIPSIZE_END_VALUE:
return TruncateAt.END;
case ELLIPSIZE_MARQUEE_VALUE:
return TruncateAt.MARQUEE;
default:
return TruncateAt.END;
}
}