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

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

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

TextView.setLines介绍

暂无

代码示例

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

TextView tv = (TextView)findViewById(R.id.editText);
if (tv != null) {
  tv.setHorizontallyScrolling(false);
  tv.setLines(3);
}

代码示例来源:origin: grantland/android-autofittextview

/**
 * {@inheritDoc}
 */
@Override
public void setLines(int lines) {
  super.setLines(lines);
  if (mHelper != null) {
    mHelper.setMaxLines(lines);
  }
}

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

@Override
public void setLines(int lines) {
  super.setLines(lines);
  adjustTextSize();
}

代码示例来源:origin: cymcsg/UltimateAndroid

/**
 * {@inheritDoc}
 */
@Override
public void setLines(int lines) {
  super.setLines(lines);
  mMaxLines = lines;
  refitText();
}

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

/**
   * 初始化textView
   *
   * @param textView     对象
   * @param layoutParams 对象
   * @param id           id
   * @param textColor    颜色值
   * @param textSize     字体大小
   * @return 返回
   */
  public TextView initText(TextView textView, LayoutParams layoutParams, int id, int textColor, int textSize) {
    if (textView == null) {
      textView = new TextView(mContext);
      textView.setId(id);
      textView.setLayoutParams(layoutParams);
      textView.setTextColor(textColor);
      textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
//            textView.setGravity(Gravity.CENTER);
      textView.setLines(mSetLines);
      textView.setSingleLine(mSetSingleLine);
//            textView.setMaxEms(mSetMaxEms);
//            textView.setEllipsize(TextUtils.TruncateAt.END);
      textView.setFilters(new InputFilter[]{new InputFilter.LengthFilter(mSetMaxEms) });
      addView(textView);
    }
    return textView;
  }

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

holder.preview.setLines(Math.max(fragment.previewLines,1));
fontSizes.setViewTextSize(holder.preview, fontSizes.getMessageListPreview());
holder.threadCount = view.findViewById(R.id.thread_count);

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

v.setLines(a.getInt(attr, -1));

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

TextView view = new TextView(this);
view.setLines(0);
TextView view1 = new TextView(this);
view1.setLines(4);
mListView.addFooterView(view, null, true);
mListView.addFooterView(view1, null, false);
mListView.setFooterDividersEnabled(true);

代码示例来源:origin: devinhu/androidone

/**
 * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
 * @param view the text view to be configured
 */
protected void configureTextView(TextView view) {
  view.setTextColor(textColor);
  view.setGravity(Gravity.CENTER);
  view.setTextSize(textSize);
  view.setLines(1);
  view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
}

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

textView2.setOnEditorActionListener(new OnEditorActionListener() {
   @Override
   public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
     v.setLines(v.getLineCount());
     return true;
   }
 });

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

TextView tv = (TextView)findViewById(R.id.editText);
if (tv != null) {
  tv.setHorizontallyScrolling(false);
  tv.setLines(3);
}

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value) {
    ((TextView)view).setLines(value.getInt());
  }
}

代码示例来源:origin: songhanghang/FaceText

@Override
public void setLines(final int lines)
 {
 super.setLines(lines);
 _maxLines=lines;
 reAdjust();
 }

代码示例来源:origin: ai212983/android-spinnerwheel

protected void onConfigureTextView(TextView textView, boolean isSelectedItem) {
  if (itemResourceId == TEXT_VIEW_ITEM_RESOURCE) {
    textView.setTextColor(textColor);
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(textSize);
    textView.setLines(1);
  }
  if (textTypeface != null) {
    textView.setTypeface(textTypeface);
  } else {
    textView.setTypeface(Typeface.SANS_SERIF, getDefaultTextStyle());
  }
}

代码示例来源:origin: boredream/DesignResCollection

/**
   * Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
   * @param view the text view to be configured
   */
  protected void configureTextView(TextView view) {
    view.setTextColor(textColor);
    view.setGravity(Gravity.CENTER);
    view.setTextSize(textSize);
    view.setEllipsize(TextUtils.TruncateAt.END);
    view.setLines(1);
//        view.setCompoundDrawablePadding(20);
//        view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
  }

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

TextView text_view = new TextView(context);
text_view.setLines(1);
text_view.setHorizontallyScrolling(true);
text_view.setMarqueeRepeatLimit(-1);  //  At this point the view is not scrolling!
...
text_view.setSelected(true);          //  Get scrolling to start

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

public void showHideMoreButton(TextView mTextView) {
  int lines = mTextView.getLineCount();

  if (lines > 2) {
    mShowMoreButton.setVisibility(View.VISIBLE);
    mTextView.setSingleLine(false);
    mTextView.setEllipsize(TextUtils.TruncateAt.END);
    mTextView.setLines(2); //no. of lines you want your textview to display
  }

}

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

final TextView dSTextView = (TextView)findViewById(R.id.annoyingTextView);
dSTextView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

  @Override
  public void onGlobalLayout() {
    dSTextView.getViewTreeObserver().removeOnGlobalLayoutListener(this);

    float lineHeight = dSTextView.getLineHeight();
    int maxLines = (int) (dSTextView.getHeight() / lineHeight);

    if (dSTextView.getLineCount() != maxLines) {
      dSTextView.setLines(maxLines);
    }

  }
});

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

final TextView dSTextView = (TextView)findViewById(R.id.annoyingTextView);
dSTextView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

  @Override
  public void onGlobalLayout() {
    dSTextView.getViewTreeObserver().removeOnGlobalLayoutListener(this);

    float lineHeight = dSTextView.getLineHeight();
    int maxLines = (int) (dSTextView.getHeight() / lineHeight);

    if (dSTextView.getLineCount() != maxLines) {
      dSTextView.setLines(maxLines);
    }

  }
});

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

final TextView dSTextView = (TextView)findViewById(R.id.annoyingTextView);
dSTextView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

  @Override
  public void onGlobalLayout() {
    dSTextView.getViewTreeObserver().removeOnGlobalLayoutListener(this);

    float lineHeight = dSTextView.getLineHeight();
    int maxLines = (int) (dSTextView.getHeight() / lineHeight);

    if (dSTextView.getLineCount() != maxLines) {
      dSTextView.setLines(maxLines);
    }

  }
});

相关文章

TextView类方法