android.widget.TextView.setEllipsize()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.0k)|赞(0)|评价(0)|浏览(208)

本文整理了Java中android.widget.TextView.setEllipsize()方法的一些代码示例,展示了TextView.setEllipsize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.setEllipsize()方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:setEllipsize

TextView.setEllipsize介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

final int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android");
 final TextView title = (TextView)getWindow().findViewById(actionBarTitle);
 if ( title != null ) {
   title.setEllipsize(TextUtils.TruncateAt.MIDDLE);
 }

代码示例来源:origin: k9mail/k-9

/**
 * Expand or collapse a TextView by removing or adding the 2 lines limitation
 */
private void expand(TextView v, boolean expand) {
  if (expand) {
    v.setMaxLines(Integer.MAX_VALUE);
    v.setEllipsize(null);
  } else {
    v.setMaxLines(2);
    v.setEllipsize(android.text.TextUtils.TruncateAt.END);
  }
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void setEllipsize(TextUtils.TruncateAt where) {
  super.setEllipsize(where);
  fixSpannableEllipsis();
}

代码示例来源:origin: lygttpod/SuperTextView

public void setMaxEms(int topMaxEms, int centerMaxEms, int bottomMaxEms) {
  if (topMaxEms != 0) {
    topTextView.setEllipsize(TextUtils.TruncateAt.END);
    topTextView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(topMaxEms)});
  }
  if (centerMaxEms != 0) {
    centerTextView.setEllipsize(TextUtils.TruncateAt.END);
    centerTextView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(centerMaxEms)});
  }
  if (bottomMaxEms != 0) {
    bottomTextView.setEllipsize(TextUtils.TruncateAt.END);
    bottomTextView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(bottomMaxEms)});
  }
}

代码示例来源:origin: JZ-Darkal/AndroidHttpCapture

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.layout_loading2_dialog);
  TextView mMessage = (TextView) findViewById(R.id.loading_dialog_message);
  if ((mText == null) || (mText.equals(""))) {
    mMessage.setVisibility(View.GONE);
  } else {
    mMessage.setVisibility(View.VISIBLE);
    mMessage.setSingleLine(mSingleLine);
    mMessage.setEllipsize(TextUtils.TruncateAt.END);
    mMessage.setText(mText);
  }
  mProgressWheel = (ProgressWheel) findViewById(R.id.progressBar);
}

代码示例来源:origin: dongjunkun/DropDownMenu

private void addTab(@NonNull List<String> tabTexts, int i) {
  final TextView tab = new TextView(getContext());
  tab.setSingleLine();
  tab.setEllipsize(TextUtils.TruncateAt.END);
  tab.setGravity(Gravity.CENTER);
  tab.setTextSize(TypedValue.COMPLEX_UNIT_PX,menuTextSize);
  tab.setLayoutParams(new LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1.0f));
  tab.setTextColor(textUnselectedColor);
  tab.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(menuUnselectedIcon), null);
  tab.setText(tabTexts.get(i));
  tab.setPadding(dpTpPx(5), dpTpPx(12), dpTpPx(5), dpTpPx(12));
  //添加点击事件
  tab.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      switchMenu(tab);
    }
  });
  tabMenuView.addView(tab);
  //添加分割线
  if (i < tabTexts.size() - 1) {
    View view = new View(getContext());
    view.setLayoutParams(new LayoutParams(dpTpPx(0.5f), ViewGroup.LayoutParams.MATCH_PARENT));
    view.setBackgroundColor(dividerColor);
    tabMenuView.addView(view);
  }
}

代码示例来源:origin: Naoki2015/CircleDemo

mCenterText.setSingleLine();
mCenterText.setGravity(Gravity.CENTER);
mCenterText.setEllipsize(TextUtils.TruncateAt.END);
mSubTitleText.setEllipsize(TextUtils.TruncateAt.END);

代码示例来源:origin: LitePalFramework/LitePal

@Override
public View getView(int position, View convertView, ViewGroup parent) {
  List<String> dataList = getItem(position);
  LinearLayout layout;
  if (convertView == null) {
    layout = new LinearLayout(getContext());
  } else {
    layout = (LinearLayout) convertView;
  }
  layout.removeAllViews();
  int width = Utility.dp2px(getContext(), 100);
  int height = Utility.dp2px(getContext(), 30);
  for (String data : dataList) {
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(width, height);
    TextView textView = new TextView(getContext());
    textView.setText(data);
    textView.setSingleLine(true);
    textView.setEllipsize(TruncateAt.END);
    textView.setGravity(Gravity.CENTER_VERTICAL);
    layout.addView(textView, params);
  }
  return layout;
}

代码示例来源:origin: bingoogolapple/BGABanner-Android

mNumberIndicatorTv.setGravity(Gravity.CENTER_VERTICAL);
  mNumberIndicatorTv.setSingleLine(true);
  mNumberIndicatorTv.setEllipsize(TextUtils.TruncateAt.END);
  mNumberIndicatorTv.setTextColor(mNumberIndicatorTextColor);
  mNumberIndicatorTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mNumberIndicatorTextSize);
mTipTv.setGravity(Gravity.CENTER_VERTICAL);
mTipTv.setSingleLine(true);
mTipTv.setEllipsize(TextUtils.TruncateAt.END);
mTipTv.setTextColor(mTipTextColor);
mTipTv.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTipTextSize);

代码示例来源:origin: k9mail/k-9

holder.folderName.setEllipsize(null);
holder.folderName.setSingleLine(false);
holder.folderName.setEllipsize(TruncateAt.START);
holder.folderName.setSingleLine(true);

代码示例来源:origin: rey5137/material

mNameView.setGravity(GravityCompat.START);
mNameView.setSingleLine(true);
mNameView.setEllipsize(TextUtils.TruncateAt.END);
int nameTextSize = a.getDimensionPixelSize(R.styleable.ContactView_cv_nameTextSize, 0);
ColorStateList nameTextColor = a.getColorStateList(R.styleable.ContactView_cv_nameTextColor);
mAddressView.setGravity(GravityCompat.START);
mAddressView.setSingleLine(true);
mAddressView.setEllipsize(TextUtils.TruncateAt.END);
int addressTextSize = a.getDimensionPixelSize(R.styleable.ContactView_cv_addressTextSize, 0);
ColorStateList addressTextColor = a.getColorStateList(R.styleable.ContactView_cv_addressTextColor);

代码示例来源:origin: rey5137/material

switch (labelEllipsize) {
  case 1:
    getLabelView().setEllipsize(TextUtils.TruncateAt.START);
    break;
  case 2:
    getLabelView().setEllipsize(TextUtils.TruncateAt.MIDDLE);
    break;
  case 3:
    getLabelView().setEllipsize(TextUtils.TruncateAt.END);
    break;
  case 4:
    getLabelView().setEllipsize(TextUtils.TruncateAt.MARQUEE);
    break;
  default:
    getLabelView().setEllipsize(TextUtils.TruncateAt.END);
    break;

代码示例来源:origin: stackoverflow.com

TextView textView = (TextView) this.findViewById(R.id.textview_marquee);  
textView.setEllipsize(TruncateAt.MARQUEE);
textView.setText("General Information... general information... General Information");
textView.setSelected(true);
textView.setSingleLine(true);

代码示例来源:origin: ISchwarz23/SortableTableView

@Override
  public View getHeaderView(final int columnIndex, final ViewGroup parentView) {
    final TextView textView = new TextView(getContext());

    if (columnIndex < headers.length) {
      textView.setText(headers[columnIndex]);
      textView.setGravity(gravity);
    }

    textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
    textView.setTypeface(textView.getTypeface(), typeface);
    textView.setTextSize(textSize);
    textView.setTextColor(textColor);
    textView.setSingleLine();
    textView.setEllipsize(TextUtils.TruncateAt.END);

    return textView;
  }
}

代码示例来源:origin: ISchwarz23/SortableTableView

@Override
public View getCellView(final int rowIndex, final int columnIndex, final ViewGroup parentView) {
  final TextView textView = new TextView(getContext());
  textView.setPadding(paddingLeft, paddingTop, paddingRight, paddingBottom);
  textView.setTypeface(textView.getTypeface(), typeface);
  textView.setTextSize(textSize);
  textView.setTextColor(textColor);
  textView.setSingleLine();
  textView.setEllipsize(TextUtils.TruncateAt.END);
  try {
    final String textToShow = getItem(rowIndex)[columnIndex];
    textView.setText(textToShow);
    textView.setGravity(gravity);
  } catch (final IndexOutOfBoundsException e) {
    Log.w(LOG_TAG, "No Sting given for row " + rowIndex + ", column " + columnIndex + ". "
        + "Caught exception: " + e.toString());
    // Show no text
  }
  return textView;
}

代码示例来源:origin: stackoverflow.com

class MyCBPref extends CheckBoxPreference{
 public MyCBPref( Context context, AttributeSet attrs){
  super(context, attrs);
 }
 protected void onBindView( View view){
  super.onBindView(view);
  makeMultiline(view); 
 }
 protected void makeMultiline( View view)
 {
  if ( view instanceof ViewGroup){

    ViewGroup grp=(ViewGroup)view;

    for ( int index = 0; index < grp.getChildCount(); index++)
    {
      makeMultiline(grp.getChildAt(index));
    }
  } else if (view instanceof TextView){
    TextView t = (TextView)view;
    t.setSingleLine(false); 
    t.setEllipsize(null);
  }
 }
}

代码示例来源:origin: flipkart-incubator/proteus

@Override
 public void setString(T view, String value) {
  Enum ellipsize = ParseHelper.parseEllipsize(value);
  view.setEllipsize((android.text.TextUtils.TruncateAt) ellipsize);
 }
});

代码示例来源:origin: rockon999/LeanbackLauncher

private TextView createTextView(float textSize, int textColor) {
  TextView textView = new TextView(getContext());
  textView.setTypeface(this.mTypeface);
  textView.setTextSize(0, textSize);
  textView.setTextColor(textColor);
  textView.setEllipsize(TruncateAt.END);
  textView.setTextDirection(5);
  return textView;
}

代码示例来源:origin: raphaelbussa/HeaderView

@SuppressLint("RtlHardcoded")
private void addEmail() {
  email = new TextView(getContext());
  email.setTextColor(hvTextColor);
  email.setGravity(Gravity.CENTER_VERTICAL | (hvIsRTL ? Gravity.RIGHT : Gravity.LEFT));
  email.setMaxLines(1);
  email.setEllipsize(TextUtils.TruncateAt.END);
  addView(email, 5);
}

代码示例来源:origin: zulip/zulip-android

@Override
  public boolean onLongClick(View v) {
    messageHeaderHolder.topicTextView.setMaxLines(Integer.MAX_VALUE);
    messageHeaderHolder.topicTextView.setEllipsize(null);
    ((MessageHeaderParent) getItem(position)).setTopicExpanded(true);
    return true;
  }
});

相关文章

TextView类方法