List of usage examples for android.widget TextView setEllipsize
public void setEllipsize(TextUtils.TruncateAt where)
From source file:Main.java
protected static void makeMultiline(View view) { if (view instanceof ViewGroup) { ViewGroup grp = (ViewGroup) view; for (int index = 0; index < grp.getChildCount(); index++) { makeMultiline(grp.getChildAt(index)); }/*from w w w. j ava 2 s .c o m*/ } else if (view instanceof TextView) { TextView t = (TextView) view; t.setSingleLine(false); t.setEllipsize(null); } }
From source file:Main.java
private static void addText(Activity activity, String text, LinearLayout layout, int maxWidth) { TextView textView = new TextView(activity); textView.setTextSize(textSize);//from w ww .j av a2 s. c o m textView.setMaxWidth(maxWidth); textView.setEllipsize(TextUtils.TruncateAt.END); textView.setText(text + " "); layout.addView(textView); }
From source file:io.github.mkjung.ivi.gui.helpers.UiTools.java
/** * Set the alignment mode of the specified TextView with the desired align * mode from preferences.//w w w.j av a 2 s . co m * * See @array/audio_title_alignment_values * * @param alignMode Align mode as read from preferences * @param t Reference to the textview */ @BindingAdapter({ "alignMode" }) public static void setAlignModeByPref(TextView t, int alignMode) { switch (alignMode) { case 0: break; case 1: t.setEllipsize(TextUtils.TruncateAt.END); break; case 2: t.setEllipsize(TextUtils.TruncateAt.START); break; case 3: t.setEllipsize(TextUtils.TruncateAt.MARQUEE); t.setMarqueeRepeatLimit(-1); t.setSelected(true); break; } }
From source file:com.ouyangzn.github.utils.UiUtils.java
public static TextView setCenterTitle(Toolbar toolbar, String title) { TextView titleView = new TextView(toolbar.getContext()); titleView.setGravity(Gravity.CENTER); titleView.setTextAppearance(toolbar.getContext(), R.style.Toolbar_titleTextAppearance); titleView.setSingleLine();// w w w. j av a 2 s . c om titleView.setEllipsize(TextUtils.TruncateAt.END); titleView.setText(title); ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); titleView.setLayoutParams(params); Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT); lp.gravity = Gravity.CENTER; toolbar.addView(titleView, lp); return titleView; }
From source file:com.hellofyc.base.util.ViewUtils.java
/** * ??//from w w w . j a va 2 s . c om */ public static void setMarqueeEnabled(TextView textView) { textView.setSelected(true); textView.setSingleLine(true); textView.setMarqueeRepeatLimit(-1); textView.setEllipsize(TruncateAt.MARQUEE); }
From source file:com.mods.grx.settings.utils.Utils.java
public static void animate_textview_marquee(TextView textView) { textView.setTextIsSelectable(true);//w ww. j a v a 2 s . co m textView.setSingleLine(true); textView.setHorizontallyScrolling(true); textView.setEllipsize(TextUtils.TruncateAt.MARQUEE); textView.setMarqueeRepeatLimit(1); }
From source file:com.mods.grx.settings.utils.Utils.java
public static void animate_textview_marquee_forever(TextView textView) { textView.setTextIsSelectable(true);//from www . ja v a 2 s .co m textView.setSingleLine(true); textView.setHorizontallyScrolling(true); textView.setEllipsize(TextUtils.TruncateAt.MARQUEE); }
From source file:Main.java
/** * Make a textview to a collapsible textview with the indicator on the right of the textview * // ww w . j ava2 s.co m * @param tv , {@link TextView} to be converted * @param upDrawableResId , drawable resource id to be used as up indicator * @param downDrawableResId , drawable resource id to be used as down indicator * @param lineTreshold , no of line to be displayed for the collapsed state */ public static void makeCollapsible(final TextView tv, int upDrawableResId, int downDrawableResId, final int lineTreshold) { final Drawable[] drawables = tv.getCompoundDrawables(); final Drawable up = tv.getContext().getResources().getDrawable(upDrawableResId); final Drawable down = tv.getContext().getResources().getDrawable(downDrawableResId); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); tv.setEllipsize(TruncateAt.END); tv.setMaxLines(lineTreshold); tv.setTag(true); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v instanceof TextView) { TextView tv = (TextView) v; boolean snippet = (Boolean) tv.getTag(); if (snippet) { // show everything snippet = false; tv.setMaxLines(Integer.MAX_VALUE); tv.setEllipsize(null); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], up, drawables[3]); } else { // show snippet snippet = true; tv.setMaxLines(lineTreshold); tv.setEllipsize(TruncateAt.END); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); } tv.setTag(snippet); } } }); } else { tv.addTextChangedListener(new TextWatcher() { @Override public void afterTextChanged(Editable arg0) { ViewTreeObserver vto = tv.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @SuppressWarnings("deprecation") @SuppressLint("NewApi") @Override public void onGlobalLayout() { tv.setEllipsize(TruncateAt.END); int line = tv.getLineCount(); tv.setMaxLines(lineTreshold); if (line <= lineTreshold) { tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { // empty listener // Log.d("line count", "count: "+ // tv.getLineCount()); } }); if (tv.getLayout() != null) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { tv.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { tv.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } return; } tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); tv.setTag(true); tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (v instanceof TextView) { TextView tv = (TextView) v; boolean snippet = (Boolean) tv.getTag(); if (snippet) { snippet = false; // show everything tv.setMaxLines(Integer.MAX_VALUE); tv.setEllipsize(null); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], up, drawables[3]); } else { snippet = true; // show snippet tv.setMaxLines(lineTreshold); tv.setEllipsize(TruncateAt.END); tv.setCompoundDrawablesWithIntrinsicBounds(drawables[0], drawables[1], down, drawables[3]); } tv.setTag(snippet); } } }); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { tv.getViewTreeObserver().removeGlobalOnLayoutListener(this); } else { tv.getViewTreeObserver().removeOnGlobalLayoutListener(this); } } }); } @Override public void beforeTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } @Override public void onTextChanged(CharSequence arg0, int arg1, int arg2, int arg3) { } }); } }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
/** Fix CR ALPS00839693,the "Phone" should be translated into Chinese */ public static void setAccountName(final TextView textView, final AccountWithDataSet account, Activity activity) {/*from w ww . j a v a2s . c om*/ if (AccountTypeUtils.ACCOUNT_NAME_LOCAL_PHONE.equals(account.name)) { textView.setText(activity.getString(R.string.contact_editor_prompt_one_account, activity.getString(R.string.account_phone_only))); } else { textView.setText(activity.getString(R.string.contact_editor_prompt_one_account, account.name)); } // set ellip size for extra large font size textView.setSingleLine(); textView.setEllipsize(TruncateAt.END); }
From source file:org.gnucash.android.util.QualifiedAccountNameCursorAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { super.bindView(view, context, cursor); TextView textView = (TextView) view.findViewById(android.R.id.text1); textView.setEllipsize(TextUtils.TruncateAt.MIDDLE); }