当前位置: 首页>>代码示例>>Java>>正文


Java TruncateAt类代码示例

本文整理汇总了Java中android.text.TextUtils.TruncateAt的典型用法代码示例。如果您正苦于以下问题:Java TruncateAt类的具体用法?Java TruncateAt怎么用?Java TruncateAt使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


TruncateAt类属于android.text.TextUtils包,在下文中一共展示了TruncateAt类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTruncatedText

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
private CharSequence getTruncatedText(int availWidth) {
    final TextPaint paint = getPaint();

    // Calculate the width the template takes.
    final String emptyTemplate = String.format(mTemplate, "");
    final float emptyTemplateWidth = paint.measureText(emptyTemplate);

    // Calculate the available width for the content.
    final float contentWidth = Math.max(availWidth - emptyTemplateWidth, 0.f);

    // Ellipsize the content to the available width.
    CharSequence clipped = TextUtils.ellipsize(mContent, paint, contentWidth, TruncateAt.END);

    // Build the full string, which should fit within availWidth.
    return String.format(mTemplate, clipped);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:TemplatePreservingTextView.java

示例2: onMeasure

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
@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);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:19,代码来源:EmojiTextView.java

示例3: a

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
private void a() {
    this.b = new TextView(this.a.F);
    this.b.setTextColor(Color.rgb(255, 255, 255));
    this.b.setTextSize(15.0f);
    this.b.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199));
    this.b.setGravity(3);
    this.b.setEllipsize(TruncateAt.END);
    this.b.setIncludeFontPadding(false);
    this.b.setSingleLine(true);
    ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, -2);
    layoutParams.weight = 1.0f;
    layoutParams.leftMargin = this.a.a(4);
    addView(this.b, layoutParams);
    this.c = new Button(this.a.F);
    this.c.setPadding(0, 0, 0, 0);
    this.c.setTextSize(16.0f);
    this.c.setTextColor(Color.rgb(255, 255, 255));
    this.c.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199));
    this.c.setIncludeFontPadding(false);
    this.c.setOnClickListener(new f(this.a, this.d.a));
    layoutParams = new LinearLayout.LayoutParams(this.a.a(TaskGuide.p), this.a.a(TaskGuide.q));
    layoutParams.leftMargin = this.a.a(2);
    layoutParams.rightMargin = this.a.a(8);
    addView(this.c, layoutParams);
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:26,代码来源:TaskGuide.java

示例4: findView

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
private void findView() {
    this.txt_notice_good_morning_sub_title = (TextView) findViewById(R.id
            .txt_notice_good_morning_sub_title);
    this.txt_notice_diet_sub_title = (TextView) findViewById(R.id.txt_notice_diet_sub_title);
    this.txt_notice_sport_sub_title = (TextView) findViewById(R.id.txt_notice_sport_sub_title);
    this.txt_notice_water_sub_title = (TextView) findViewById(R.id.txt_notice_water_sub_title);
    this.txt_notice_box_count = (TextView) findViewById(R.id.txt_notice_box_count);
    this.txt_notice_good_morning_sub_title.setEllipsize(TruncateAt.END);
    this.txt_notice_diet_sub_title.setEllipsize(TruncateAt.END);
    this.txt_notice_sport_sub_title.setEllipsize(TruncateAt.END);
    this.txt_notice_water_sub_title.setEllipsize(TruncateAt.END);
    this.tb_notice_good_morning = (ToggleButton) findViewById(R.id.tb_notice_good_morning);
    this.tb_notice_diet = (ToggleButton) findViewById(R.id.tb_notice_diet);
    this.tb_notice_sport = (ToggleButton) findViewById(R.id.tb_notice_sport);
    this.tb_notice_water = (ToggleButton) findViewById(R.id.tb_notice_water);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:17,代码来源:BooheeNoticeActivity.java

示例5: setTitle

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public void setTitle(CharSequence title) {
    if (!TextUtils.isEmpty(title)) {
        if (this.mTitleTextView == null) {
            Context context = getContext();
            this.mTitleTextView = new TextView(context);
            this.mTitleTextView.setSingleLine();
            this.mTitleTextView.setEllipsize(TruncateAt.END);
            if (this.mTitleTextAppearance != 0) {
                this.mTitleTextView.setTextAppearance(context, this.mTitleTextAppearance);
            }
            if (this.mTitleTextColor != 0) {
                this.mTitleTextView.setTextColor(this.mTitleTextColor);
            }
        }
        if (!isChildOrHidden(this.mTitleTextView)) {
            addSystemView(this.mTitleTextView, true);
        }
    } else if (this.mTitleTextView != null && isChildOrHidden(this.mTitleTextView)) {
        removeView(this.mTitleTextView);
        this.mHiddenViews.remove(this.mTitleTextView);
    }
    if (this.mTitleTextView != null) {
        this.mTitleTextView.setText(title);
    }
    this.mTitleText = title;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:Toolbar.java

示例6: setSubtitle

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public void setSubtitle(CharSequence subtitle) {
    if (!TextUtils.isEmpty(subtitle)) {
        if (this.mSubtitleTextView == null) {
            Context context = getContext();
            this.mSubtitleTextView = new TextView(context);
            this.mSubtitleTextView.setSingleLine();
            this.mSubtitleTextView.setEllipsize(TruncateAt.END);
            if (this.mSubtitleTextAppearance != 0) {
                this.mSubtitleTextView.setTextAppearance(context, this.mSubtitleTextAppearance);
            }
            if (this.mSubtitleTextColor != 0) {
                this.mSubtitleTextView.setTextColor(this.mSubtitleTextColor);
            }
        }
        if (!isChildOrHidden(this.mSubtitleTextView)) {
            addSystemView(this.mSubtitleTextView, true);
        }
    } else if (this.mSubtitleTextView != null && isChildOrHidden(this.mSubtitleTextView)) {
        removeView(this.mSubtitleTextView);
        this.mHiddenViews.remove(this.mSubtitleTextView);
    }
    if (this.mSubtitleTextView != null) {
        this.mSubtitleTextView.setText(subtitle);
    }
    this.mSubtitleText = subtitle;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:Toolbar.java

示例7: getView

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_doc_list, parent, false);
    }

    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final View line2 = convertView.findViewById(R.id.line2);

    final DocumentStack stack = getItem(position);
    iconMime.setImageDrawable(stack.root.loadIcon(context));

    final Drawable crumb = ContextCompat.getDrawable(context, R.drawable.ic_breadcrumb_arrow);
    crumb.setBounds(0, 0, crumb.getIntrinsicWidth(), crumb.getIntrinsicHeight());

    final SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(stack.root.title);
    for (int i = stack.size() - 2; i >= 0; i--) {
        appendDrawable(builder, crumb);
        builder.append(stack.get(i).displayName);
    }
    title.setText(builder);
    title.setEllipsize(TruncateAt.MIDDLE);

    if (line2 != null) line2.setVisibility(View.GONE);

    return convertView;
}
 
开发者ID:medalionk,项目名称:simple-share-android,代码行数:33,代码来源:RecentsCreateFragment.java

示例8: setSubtitle

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public void setSubtitle(CharSequence charSequence) {
    if (!TextUtils.isEmpty(charSequence)) {
        if (this.f1243d == null) {
            Context context = getContext();
            this.f1243d = new TextView(context);
            this.f1243d.setSingleLine();
            this.f1243d.setEllipsize(TruncateAt.END);
            if (this.f1252m != 0) {
                this.f1243d.setTextAppearance(context, this.f1252m);
            }
            if (this.f1264y != 0) {
                this.f1243d.setTextColor(this.f1264y);
            }
        }
        if (!m2431d(this.f1243d)) {
            m2421a(this.f1243d, true);
        }
    } else if (this.f1243d != null && m2431d(this.f1243d)) {
        removeView(this.f1243d);
        this.f1228C.remove(this.f1243d);
    }
    if (this.f1243d != null) {
        this.f1243d.setText(charSequence);
    }
    this.f1262w = charSequence;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:27,代码来源:Toolbar.java

示例9: setTitle

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public void setTitle(CharSequence charSequence) {
    if (!TextUtils.isEmpty(charSequence)) {
        if (this.f1242c == null) {
            Context context = getContext();
            this.f1242c = new TextView(context);
            this.f1242c.setSingleLine();
            this.f1242c.setEllipsize(TruncateAt.END);
            if (this.f1251l != 0) {
                this.f1242c.setTextAppearance(context, this.f1251l);
            }
            if (this.f1263x != 0) {
                this.f1242c.setTextColor(this.f1263x);
            }
        }
        if (!m2431d(this.f1242c)) {
            m2421a(this.f1242c, true);
        }
    } else if (this.f1242c != null && m2431d(this.f1242c)) {
        removeView(this.f1242c);
        this.f1228C.remove(this.f1242c);
    }
    if (this.f1242c != null) {
        this.f1242c.setText(charSequence);
    }
    this.f1261v = charSequence;
}
 
开发者ID:Qwaz,项目名称:solved-hacking-problem,代码行数:27,代码来源:Toolbar.java

示例10: addText

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
private void addText(boolean isLeftToRight) {
	textView = new TextView(ActivityManager.getActivity());
	textView.setText(text);
	textView.setSingleLine(true);
	textView.setTextColor(isEnable?AndroidUIUtil.WIN_FONT_COLOR.toAndroid():AndroidUIUtil.WIN_FONT_DISABLE_COLOR.toAndroid());
	UICore.setTextSize(textView, getScreenAdapterAdAPI());
	textView.setMaxWidth(300);
	textView.setEllipsize(TruncateAt.MARQUEE);
	textView.setGravity(Gravity.CENTER_VERTICAL | (isLeftToRight?Gravity.LEFT:Gravity.RIGHT));
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	lp.gravity = textView.getGravity();
	if(isLeftToRight){
		lp.leftMargin = 5;
	}else{
		lp.rightMargin = 5;
	}
	AndroidUIUtil.addView(defaultLinearLayout, textView, lp, viewRelation);
}
 
开发者ID:javalovercn,项目名称:j2se_for_android,代码行数:20,代码来源:JMenuItem.java

示例11: createQuestionTextView

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
private TextView createQuestionTextView(MQuestion question, boolean isLastItem) {
	TextView textView = new TextView(getContext());
	textView.setMaxLines(3);
	textView.setEllipsize(TruncateAt.END);
	String description = removeBlankLine(question.description);
	textView.setText(description);
	
	int vPadding = getResources().getDimensionPixelSize(R.dimen.question_item_padding_v);
	textView.setPadding(mPadding, vPadding, mPadding, isLastItem ? vPadding : 0);
	
	int textColor = getResources().getColor(R.color.favorite_folder_question_desc);
	textView.setTextColor(textColor);
	
	int textSize = getResources().getDimensionPixelSize(R.dimen.favorite_folder_question_text_size);
	textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
	
	return textView;
}
 
开发者ID:fengyanjava,项目名称:msb-android,代码行数:19,代码来源:FavoriteFolderItemView.java

示例12: dzn

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public dzn(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  this.a = loj.a(paramContext);
  this.g = new dzo(paramContext);
  if (!this.c) {}
  for (int i1 = 19;; i1 = 10)
  {
    Button localButton = lur.a(paramContext, paramAttributeSet, paramInt, i1, this.a.aQ, 0);
    localButton.setSingleLine(true);
    localButton.setEllipsize(TextUtils.TruncateAt.END);
    localButton.setCompoundDrawablePadding(this.a.n);
    localButton.setOnClickListener(this);
    this.i = localButton;
    this.i.setText(getContext().getString(aau.iJ));
    this.l = new MediaView(paramContext, paramAttributeSet, paramInt);
    this.l.setOnClickListener(this);
    this.l.setContentDescription(getResources().getString(aau.dg));
    this.h = new ArrayList();
    this.j = new ImageView(paramContext, paramAttributeSet, paramInt);
    this.j.setImageBitmap(this.a.f);
    this.j.setScaleType(ImageView.ScaleType.CENTER);
    this.o = new TextView(paramContext, paramAttributeSet, paramInt);
    return;
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:27,代码来源:dzn.java

示例13: dxm

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
private dxm(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, 0);
  this.a = new TextView(paramContext);
  this.a.setGravity(17);
  this.a.setMaxLines(2);
  this.a.setEllipsize(TextUtils.TruncateAt.END);
  this.a.setGravity(1);
  this.a.setTextAppearance(paramContext, efj.yu);
  this.b = new ImageView(paramContext);
  this.b.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  this.i = ((lwj)mbb.a(paramContext, lwj.class));
  Resources localResources = paramContext.getResources();
  setBackgroundResource(da.aY);
  if (e == 0)
  {
    e = (int)localResources.getDimension(efj.mq);
    f = (int)localResources.getDimension(efj.mo);
    g = (int)localResources.getDimension(efj.ml);
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:22,代码来源:dxm.java

示例14: dws

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public dws(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  if (!f)
  {
    Resources localResources = paramContext.getResources();
    a = localResources.getString(aau.gh);
    g = localResources.getDimension(efj.nK);
    h = localResources.getColor(efj.ko);
    f = true;
  }
  float f1 = g;
  int i = h;
  TextView localTextView = new TextView(paramContext, paramAttributeSet, paramInt);
  localTextView.setTextSize(0, f1);
  localTextView.setSingleLine(true);
  localTextView.setTextColor(i);
  localTextView.setEllipsize(TextUtils.TruncateAt.END);
  this.c = localTextView;
  addView(this.c);
  this.b = new dvb(paramContext, paramAttributeSet, paramInt);
  addView(this.b);
  this.d = 0;
  this.e = 0;
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:26,代码来源:dws.java

示例15: dwq

import android.text.TextUtils.TruncateAt; //导入依赖的package包/类
public dwq(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  this.j = paramContext;
  this.i = paramAttributeSet;
  this.k = paramInt;
  Resources localResources = paramContext.getResources();
  if (!d)
  {
    e = localResources.getColor(efj.kp);
    f = localResources.getDimension(efj.nK);
    g = localResources.getColor(efj.kp);
    h = localResources.getDimension(efj.nJ);
    d = true;
  }
  float f1 = f;
  int m = e;
  TextView localTextView = new TextView(paramContext, paramAttributeSet, paramInt);
  localTextView.setTextSize(0, f1);
  localTextView.setSingleLine(true);
  localTextView.setTextColor(m);
  localTextView.setEllipsize(TextUtils.TruncateAt.END);
  localTextView.setTypeface(Typeface.DEFAULT_BOLD);
  this.a = localTextView;
  addView(this.a);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:27,代码来源:dwq.java


注:本文中的android.text.TextUtils.TruncateAt类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。