本文整理匯總了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;
}
}