本文整理了Java中android.widget.TextView.getLineHeight()
方法的一些代码示例,展示了TextView.getLineHeight()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getLineHeight()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getLineHeight
暂无
代码示例来源:origin: square/assertj-android
public S hasLineHeight(int height) {
isNotNull();
int actualHeight = actual.getLineHeight();
assertThat(actualHeight) //
.overridingErrorMessage("Expected line height <%s> but was <%s>.", height, actualHeight) //
.isEqualTo(height);
return myself;
}
代码示例来源:origin: wangdan/AisenWeiBo
lineH = textView.getLineHeight();
代码示例来源:origin: wangdan/AisenWeiBo
int lineHeight = tv.getLineHeight();
value.setSpan(backgroundColorSpan, findStart, findEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
代码示例来源:origin: stackoverflow.com
TextView tv = (TextView) findViewById(R.id.TextView02);
int height_in_pixels = tv.getLineCount() * tv.getLineHeight(); //approx height text
tv.setHeight(height_in_pixels);
代码示例来源:origin: MoMoWait/LeanbackLauncher
private int getDescriptionMaxHeight(Context context, TextView title) {
Resources res = context.getResources();
return (int) ((((float) ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getHeight()) - (2.0f * res.getDimension(R.dimen.lb_dialog_list_item_vertical_padding))) - ((float) ((res.getInteger(R.integer.lb_dialog_action_title_max_lines) * 2) * title.getLineHeight())));
}
}
代码示例来源:origin: stackoverflow.com
int scrollY; // This is your current scroll position in pixels.
int scrollViewHeight; // This is the height of your scrolling window.
TextView textView; // This is the TextView we're considering.
String text = (String) textView.getText();
int charsPerLine = text.length() / textView.getLineCount();
int lineHeight = textView.getLineHeight();
int startLine = scrollY / lineHeight;
int endLine = startLine + scrollViewHeight/lineHeight + 1;
int startChar = charsPerLine * startLine;
int endChar = charsPerLine * (endLine+1) + 1;
String approxVisibleString = text.substring(startChar, endChar);
代码示例来源:origin: stackoverflow.com
final TextView msgView = (TextView)view_aux.findViewById(R.id.accordion_msg);
String msg_text = dbStructure.getMsg();
if(msg_text.contains("href=\"")) {
String[] msg_aux = msg_text.split("href=\"");
if (!msg_aux[1].toLowerCase().startsWith("http"))
msg_aux[1] = "http://" + msg_aux[1];
msg_text = msg_aux[0] + "\"href=\"" + msg_aux[1];
}
msgView.setText(Html.fromHtml(msg_text));
msgView.setMovementMethod(LinkMovementMethod.getInstance());
int lines = (int)Math.round(height / msgView.getLineHeight());
SpannableString ss = new SpannableString(msgView.getText());
ss.setSpan(new MyLeadingMarginSpan2(lines, width+10), 0, ss.length(), 0);
msgView.setText(ss);
代码示例来源:origin: stackoverflow.com
ViewGroup layout=new LinearLayout(context);
TextView tv=new TextView(context); //your text
tv.setText("my text");
ImageView imageView=new ImageView(context); //your icon
//filling image view with icon bitmap (in this case from resource)
imageView.setImageBitmap(BitmapFactory.decodeStream(context.getResources().openRawResource(resourceId)));
//ensuring that icon size will be more or less like text height
imageView.setAdjustViewBounds(true);
imageView.setMaxHeight((int )(tv.getLineHeight()*1.5));
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
layout.addView(imageView); //adding icon
tv.setGravity(Gravity.BOTTOM|Gravity.LEFT);
layout.addView(tv); //adding text
代码示例来源:origin: com.squareup.assertj/assertj-android
public S hasLineHeight(int height) {
isNotNull();
int actualHeight = actual.getLineHeight();
assertThat(actualHeight) //
.overridingErrorMessage("Expected line height <%s> but was <%s>.", height, actualHeight) //
.isEqualTo(height);
return myself;
}
代码示例来源:origin: sangxiaonian/AliBehaver
@Override
public void run() {
int lineCount= tv.getLineCount();
int height = tv.getLineHeight();
FloatView.this.mheight=tv.getHeight();
if (lineCount>lines){
isExpand=false;
changeHeight(height*lines);
ftv.setVisibility(VISIBLE);
}else {
isExpand=true;
ftv.setVisibility(GONE);
}
}
});
代码示例来源:origin: hibernate2011/RosClient
@Override
public void run() {
if(tvLog.getText().length() > 2000) {
tvLog.setText("");
}
tvLog.setText(tvLog.getText() + "\ninfo: " + event.msg + "\n");
int offset=tvLog.getLineCount()*tvLog.getLineHeight();
if(offset>tvLog.getHeight()){
tvLog.scrollTo(0,offset-tvLog.getHeight());
}
}
});
代码示例来源:origin: CNCoderX/ExpandableTextView
private int getLinesHeight(int lines) {
int lineHeight = mTextView.getLineHeight() * lines;
int padding = mTextView.getCompoundPaddingTop() + mTextView.getCompoundPaddingBottom();
return lineHeight + padding;
}
代码示例来源:origin: stackoverflow.com
private void TextMeasure(String text,
TextView tvl, TextView tvr) {
int linesPerScreen = tvl.getHeight() / (tvl.getLineHeight() + (int) tvl.getLineSpacingExtra());
Paint paint = tvl.getPaint();
int textWidth = paint.breakText(text, 0, text.length(),
true, tvl.getWidth(), null);
int totalText = textWidth * linesPerScreen;
String leftText = text.substring(0, totalText);
String rightText = text.substring(totalText,
text.length());
tvl.setText(leftText);
tvr.setText(rightText);
}
代码示例来源:origin: stackoverflow.com
final TextView tv = ((TextView) myLayout.findViewById(R.id.mytextview));
tv.setText(value);
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
private int maxLines = -1;
@Override
public void onGlobalLayout() {
if (maxLines < 0 && tv.getHeight() > 0 && tv.getLineHeight() > 0) {
int height = tv.getHeight();
int lineHeight = tv.getLineHeight();
maxLines = height / lineHeight;
tv.setMaxLines(maxLines);
}
}
});
代码示例来源:origin: stackoverflow.com
public static void bringPointIntoView (TextView textView,
ScrollView scrollView, int offset)
{
int line = textView.getLayout ().getLineForOffset (offset);
int y = (int) ((line + 0.5) * textView.getLineHeight ());
scrollView.smoothScrollTo (0, y - scrollView.getHeight () / 2);
}
代码示例来源:origin: stackoverflow.com
private int getMeasuredHeight(TextView textView) {
textView.measure(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
int height = textView.getMeasuredHeight();
height += (textView.getLineCount()-1) * textView.getLineHeight();
return height;
}
代码示例来源:origin: ahmadaghazadeh/CodeEditor
public int getTopVisibleLine(TextView editor) {
int lineHeight = editor.getLineHeight();
if (lineHeight == 0) {
return 0;
}
int line = editor.getScrollY() / lineHeight;
if (line < 0) {
return 0;
}
if (line >= editor.getLineCount()) {
return editor.getLineCount() - 1;
}
return line;
}
代码示例来源: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);
}
}
});
内容来源于网络,如有侵权,请联系作者删除!