Java Code Examples for android.text.TextUtils#TruncateAt
The following examples show how to use
android.text.TextUtils#TruncateAt .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StaticLayoutEx.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static StaticLayout createStaticLayout2(CharSequence source, TextPaint paint, int width, Layout.Alignment align, float spacingmult, float spacingadd, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsisWidth, int maxLines) { if (Build.VERSION.SDK_INT >= 23) { StaticLayout.Builder builder = StaticLayout.Builder.obtain(source, 0, source.length(), paint, ellipsisWidth) .setAlignment(align) .setLineSpacing(spacingadd, spacingmult) .setIncludePad(includepad) .setEllipsize(TextUtils.TruncateAt.END) .setEllipsizedWidth(ellipsisWidth) .setMaxLines(maxLines) .setBreakStrategy(StaticLayout.BREAK_STRATEGY_HIGH_QUALITY) .setHyphenationFrequency(StaticLayout.HYPHENATION_FREQUENCY_NONE); return builder.build(); } else { return createStaticLayout(source, 0, source.length(), paint, width, align, spacingmult, spacingadd, includepad, ellipsize, ellipsisWidth, maxLines, true); } }
Example 2
Source File: FMedittext.java From Android-Music-Player with MIT License | 5 votes |
@Override public void setEllipsize(TextUtils.TruncateAt ellipsis) { if (ellipsis == TextUtils.TruncateAt.MARQUEE) { throw new IllegalArgumentException("EditText cannot use the ellipsize mode " + "TextUtils.TruncateAt.MARQUEE"); } super.setEllipsize(ellipsis); }
Example 3
Source File: TextLayoutBuilder.java From TextLayoutBuilder with Apache License 2.0 | 5 votes |
/** * Sets the ellipsis location for the layout. * * @param ellipsize The ellipsis location in the layout * @return This {@link TextLayoutBuilder} instance */ public TextLayoutBuilder setEllipsize(TextUtils.TruncateAt ellipsize) { if (mParams.ellipsize != ellipsize) { mParams.ellipsize = ellipsize; mSavedLayout = null; } return this; }
Example 4
Source File: ReactTextView.java From react-native-GPay with MIT License | 4 votes |
public void setEllipsizeLocation(TextUtils.TruncateAt ellipsizeLocation) { mEllipsizeLocation = ellipsizeLocation; }
Example 5
Source File: StaticLayoutHelper.java From TextLayoutBuilder with Apache License 2.0 | 4 votes |
/** * Returns a StaticLayout using ICS specific constructor if possible. * * @param text The text for the layout * @param start The start index * @param end The end index * @param paint The {@link TextPaint} to be used * @param width The width of the layout * @param alignment The {@link Layout.Alignment} * @param spacingMult The line spacing multiplier * @param spacingAdd The line spacing extra * @param includePadding Whether to include font padding * @param ellipsize The ellipsizing behavior specified by {@link TextUtils.TruncateAt} * @param ellipsisWidth The width of the ellipsis * @param maxLines The maximum number of lines for this layout * @param textDirection The text direction * @return A {@link StaticLayout} */ private static StaticLayout getStaticLayoutMaybeMaxLines( CharSequence text, int start, int end, TextPaint paint, int width, Layout.Alignment alignment, float spacingMult, float spacingAdd, boolean includePadding, TextUtils.TruncateAt ellipsize, int ellipsisWidth, int maxLines, TextDirectionHeuristicCompat textDirection) { try { return StaticLayoutProxy.create( text, start, end, paint, width, alignment, spacingMult, spacingAdd, includePadding, ellipsize, ellipsisWidth, maxLines, textDirection); } catch (LinkageError e) { // Use the publicly available constructor. } return getStaticLayoutNoMaxLines( text, start, end, paint, width, alignment, spacingMult, spacingAdd, includePadding, ellipsize, ellipsisWidth); }
Example 6
Source File: DefaultToastStyle.java From DevUtils with Apache License 2.0 | 4 votes |
/** * 获取 Ellipsize 效果 * @return Ellipsize 效果 */ @Override public TextUtils.TruncateAt getEllipsize() { return null; }
Example 7
Source File: TEditText.java From timecat with Apache License 2.0 | 4 votes |
@Override public TextUtils.TruncateAt getEllipsize() { return super.getEllipsize(); }
Example 8
Source File: EditTextSpec.java From litho with Apache License 2.0 | 4 votes |
@OnLoadStyle static void onLoadStyle( ComponentContext c, Output<TextUtils.TruncateAt> ellipsize, Output<Float> spacingMultiplier, Output<Integer> minLines, Output<Integer> maxLines, Output<Boolean> isSingleLine, Output<CharSequence> text, Output<ColorStateList> textColorStateList, Output<Integer> linkColor, Output<Integer> highlightColor, Output<Integer> textSize, Output<Layout.Alignment> textAlignment, Output<Integer> textStyle, Output<Float> shadowRadius, Output<Float> shadowDx, Output<Float> shadowDy, Output<Integer> shadowColor, Output<Integer> gravity, Output<Integer> inputType, Output<Integer> imeOptions) { final TypedArray a = c.obtainStyledAttributes(R.styleable.Text, 0); for (int i = 0, size = a.getIndexCount(); i < size; i++) { final int attr = a.getIndex(i); if (attr == R.styleable.Text_android_text) { text.set(a.getString(attr)); } else if (attr == R.styleable.Text_android_textColor) { textColorStateList.set(a.getColorStateList(attr)); } else if (attr == R.styleable.Text_android_textSize) { textSize.set(a.getDimensionPixelSize(attr, 0)); } else if (attr == R.styleable.Text_android_ellipsize) { final int index = a.getInteger(attr, 0); if (index > 0) { ellipsize.set(TRUNCATE_AT[index - 1]); } } else if (attr == R.styleable.Text_android_textAlignment) { if (SDK_INT >= JELLY_BEAN_MR1) { int viewTextAlignment = a.getInt(attr, -1); textAlignment.set(getAlignment(viewTextAlignment, Gravity.NO_GRAVITY)); } } else if (attr == R.styleable.Text_android_minLines) { minLines.set(a.getInteger(attr, -1)); } else if (attr == R.styleable.Text_android_maxLines) { maxLines.set(a.getInteger(attr, -1)); } else if (attr == R.styleable.Text_android_singleLine) { isSingleLine.set(a.getBoolean(attr, false)); } else if (attr == R.styleable.Text_android_textColorLink) { linkColor.set(a.getColor(attr, 0)); } else if (attr == R.styleable.Text_android_textColorHighlight) { highlightColor.set(a.getColor(attr, 0)); } else if (attr == R.styleable.Text_android_textStyle) { textStyle.set(a.getInteger(attr, 0)); } else if (attr == R.styleable.Text_android_lineSpacingMultiplier) { spacingMultiplier.set(a.getFloat(attr, 0)); } else if (attr == R.styleable.Text_android_shadowDx) { shadowDx.set(a.getFloat(attr, 0)); } else if (attr == R.styleable.Text_android_shadowDy) { shadowDy.set(a.getFloat(attr, 0)); } else if (attr == R.styleable.Text_android_shadowRadius) { shadowRadius.set(a.getFloat(attr, 0)); } else if (attr == R.styleable.Text_android_shadowColor) { shadowColor.set(a.getColor(attr, 0)); } else if (attr == R.styleable.Text_android_gravity) { gravity.set(a.getInteger(attr, 0)); } else if (attr == R.styleable.Text_android_inputType) { inputType.set(a.getInteger(attr, 0)); } else if (attr == R.styleable.Text_android_imeOptions) { imeOptions.set(a.getInteger(attr, 0)); } } a.recycle(); }
Example 9
Source File: StaticLayoutEx.java From Telegram with GNU General Public License v2.0 | 4 votes |
public static StaticLayout createStaticLayout(CharSequence source, TextPaint paint, int width, Layout.Alignment align, float spacingmult, float spacingadd, boolean includepad, TextUtils.TruncateAt ellipsize, int ellipsisWidth, int maxLines) { return createStaticLayout(source, 0, source.length(), paint, width, align, spacingmult, spacingadd, includepad, ellipsize, ellipsisWidth, maxLines, true); }
Example 10
Source File: AutoResizeTextView.java From watchlist with Apache License 2.0 | 4 votes |
@Override public void setEllipsize(TextUtils.TruncateAt where) { super.setEllipsize(where); requestLayout(); }
Example 11
Source File: AutoResizeTextView.java From memoir with Apache License 2.0 | 4 votes |
@Override public void setEllipsize(TextUtils.TruncateAt where) { super.setEllipsize(where); requestLayout(); }
Example 12
Source File: ToastTintActivity.java From DevUtils with Apache License 2.0 | 4 votes |
/** * Ellipsize 效果 * @return */ @Override public TextUtils.TruncateAt getEllipsize() { return null; }
Example 13
Source File: DevToastUse.java From DevUtils with Apache License 2.0 | 4 votes |
/** * Ellipsize 效果 * @return */ @Override public TextUtils.TruncateAt getEllipsize() { return null; }
Example 14
Source File: RichEditText.java From RichEditText with Apache License 2.0 | 4 votes |
public void setEllipsize(TextUtils.TruncateAt ellipsis) { mEditText.setEllipsize(ellipsis); }
Example 15
Source File: DSL.java From anvil with MIT License | 4 votes |
public static Void ellipsize(TextUtils.TruncateAt arg) { return BaseDSL.attr("ellipsize", arg); }
Example 16
Source File: FastTextView.java From FastTextView with Apache License 2.0 | 4 votes |
@NonNull protected StaticLayout makeLayout(CharSequence text, int maxWidth, boolean exactly) { TextUtils.TruncateAt truncateAt = getTruncateAt(); int layoutTargetWidth = maxWidth; int contentWidth = maxWidth; if (!exactly || truncateAt != null) { contentWidth = getContentWidth(text); } if (!exactly) { layoutTargetWidth = maxWidth > 0 ? Math.min(maxWidth, contentWidth) : contentWidth; } StaticLayoutBuilderCompat layoutBuilder = createStaticLayoutBuilder(text, 0, text .length(), mTextPaint, layoutTargetWidth); layoutBuilder.setLineSpacing(mAttrsHelper.mSpacingAdd, mAttrsHelper.mSpacingMultiplier) .setMaxLines(mAttrsHelper.mMaxLines) .setAlignment(TextViewAttrsHelper.getLayoutAlignment(this, getGravity())) .setIncludePad(true); if (truncateAt != null) { layoutBuilder.setEllipsize(truncateAt); EllipsisSpannedContainer ellipsisSpanned = new EllipsisSpannedContainer(text instanceof Spanned ? (Spanned) text : new SpannableString(text)); ellipsisSpanned.setCustomEllipsisSpan(mCustomEllipsisSpan); layoutBuilder.setText(ellipsisSpanned); if (contentWidth > layoutTargetWidth * mAttrsHelper.mMaxLines) { int ellipsisWithOffset = (int) mTextPaint.measureText(ReadMoreTextView.ELLIPSIS_NORMAL) - 2; // when StaticLayout call calculateEllipsis, // textWidth <= avail will cause do nothing so we should make it different with textWidth if (mCustomEllipsisSpan != null) { layoutBuilder.setEllipsizedWidth(layoutTargetWidth - mCustomEllipsisSpan.getSize (getPaint(), mText, 0, mText.length(), null) + ellipsisWithOffset); } else if (Build.VERSION.SDK_INT <= 19) { ReadMoreTextView.EllipsisSpan ellipsisSpan = new ReadMoreTextView.EllipsisSpan (ReadMoreTextView.ELLIPSIS_NORMAL); ellipsisSpanned.setCustomEllipsisSpan(ellipsisSpan); layoutBuilder.setEllipsizedWidth(layoutTargetWidth - ellipsisSpan.getSize(getPaint(), mText, 0, mText.length(), null) + ellipsisWithOffset); } else { layoutBuilder.setEllipsizedWidth(layoutTargetWidth); } } else { layoutBuilder.setEllipsizedWidth(contentWidth); } beforeStaticLayoutBuild(layoutBuilder); StaticLayout layout = layoutBuilder.build(); ellipsisSpanned.setLayout(layout); mEllipsisSpanned = ellipsisSpanned; return layout; } beforeStaticLayoutBuild(layoutBuilder); return layoutBuilder.build(); }
Example 17
Source File: TextViewUtils.java From DevUtils with Apache License 2.0 | 2 votes |
/** * 设置 Ellipsize 效果 * @param view {@link TextView} * @param where {@link TextUtils.TruncateAt} * @return {@link View} */ public static View setEllipsize(final View view, final TextUtils.TruncateAt where) { setEllipsize(getTextView(view), where); return view; }
Example 18
Source File: ToastTintUtils.java From DevUtils with Apache License 2.0 | 2 votes |
/** * 获取 Ellipsize 效果 * @return Ellipsize 效果 */ TextUtils.TruncateAt getEllipsize();
Example 19
Source File: SnackbarUse.java From DevUtils with Apache License 2.0 | 2 votes |
/** * TextView Ellipsize 效果 * @return */ public TextUtils.TruncateAt getTextEllipsize() { return null; }
Example 20
Source File: IToast.java From DevUtils with Apache License 2.0 | 2 votes |
/** * 获取 Ellipsize 效果 * @return Ellipsize 效果 */ TextUtils.TruncateAt getEllipsize();