本文整理了Java中android.widget.TextView.getMaxLines()
方法的一些代码示例,展示了TextView.getMaxLines()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getMaxLines()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getMaxLines
暂无
代码示例来源:origin: grantland/android-autofittextview
private static int getMaxLines(TextView view) {
int maxLines = -1; // No limit (Integer.MAX_VALUE also means no limit)
TransformationMethod method = view.getTransformationMethod();
if (method != null && method instanceof SingleLineTransformationMethod) {
maxLines = 1;
}
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// setMaxLines() and getMaxLines() are only available on android-16+
maxLines = view.getMaxLines();
}
return maxLines;
}
代码示例来源:origin: stackoverflow.com
private void cycleTextViewExpansion(TextView tv){
int collapsedMaxLines = 3;
ObjectAnimator animation = ObjectAnimator.ofInt(tv, "maxLines",
tv.getMaxLines() == collapsedMaxLines? tv.getLineCount() : collapsedMaxLines);
animation.setDuration(200).start();
}
代码示例来源:origin: square/assertj-android
@TargetApi(JELLY_BEAN)
public S hasMaxLines(int lines) {
isNotNull();
int actualLines = actual.getMaxLines();
assertThat(actualLines) //
.overridingErrorMessage("Expected maximum lines <%s> but was <%s>.", lines, actualLines) //
.isEqualTo(lines);
return myself;
}
代码示例来源:origin: victorminerva/AutoResizeEditText
private static int getMaxLines(TextView view) {
int maxLines = -1; // No limit (Integer.MAX_VALUE also means no limit)
TransformationMethod method = view.getTransformationMethod();
if (method != null && method instanceof SingleLineTransformationMethod) {
maxLines = 1;
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
// setMaxLines() and getMaxLines() are only available on android-16+
maxLines = view.getMaxLines();
}
return maxLines;
}
代码示例来源:origin: stackoverflow.com
TextView myTextView = rootView.getViewById(R.id.my_text_view);
if (myTextView.getLineCount() > myTextView.getMaxLines()) {
// your code here
}
代码示例来源:origin: com.squareup.assertj/assertj-android
@TargetApi(JELLY_BEAN)
public S hasMaxLines(int lines) {
isNotNull();
int actualLines = actual.getMaxLines();
assertThat(actualLines) //
.overridingErrorMessage("Expected maximum lines <%s> but was <%s>.", lines, actualLines) //
.isEqualTo(lines);
return myself;
}
代码示例来源:origin: stackoverflow.com
public static float calculateTextSizeToFit(TextView textView, String desiredText, int limitSpSize, float desiredTxtPxSize) {
Paint measurePaint = new Paint(textView.getPaint());
measurePaint.setTextSize(desiredTxtPxSize);
float pWidth = measurePaint.measureText(desiredText);
float labelWidth = textView.getWidth();
int maxLines = textView.getMaxLines();
while (labelWidth > 0 && pWidth/maxLines > labelWidth-20) {
float textSize = measurePaint.getTextSize();
measurePaint.setTextSize(textSize-1);
pWidth = measurePaint.measureText(desiredText);
if (textSize < TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_SP, limitSpSize,
textView.getContext().getResources().getDisplayMetrics())) break;
}
return measurePaint.getTextSize();
}
代码示例来源:origin: stackoverflow.com
void collapseExpandTextView(TextView tv) {
if (tv.getMaxLines() == MAX_LINE_COUNT) {
ObjectAnimator animation = ObjectAnimator.ofInt(tv, "maxLines", tv.getMaxLines());
animation.setDuration(200).start();
代码示例来源:origin: stefan-niedermann/nextcloud-deck
private CardViewHolder(View view) {
super(view);
ButterKnife.bind(this, view);
card.setOnClickListener((View clickedView) -> {
if (Build.VERSION.SDK_INT >= 16) {
cardDescription.setMaxLines(cardDescription.getMaxLines() == 3 ? Integer.MAX_VALUE : 3);
}
});
card.setOnLongClickListener((View draggedView) -> {
// Create a new ClipData.
// This is done in two steps to provide clarity. The convenience method
// ClipData.newPlainText() can create a plain text ClipData in one step.
// Create a new ClipData.Item from the ImageView object's tag
ClipData dragData = ClipData.newPlainText("TEST", "TEST2");
// Starts the drag
draggedView.startDrag(dragData, // the data to be dragged
new View.DragShadowBuilder(draggedView), // the drag shadow builder
draggedView, // no need to use local data
0 // flags (not currently used, set to 0)
);
view.setVisibility(View.INVISIBLE);
DeckLog.log("onLongClickListener");
return true;
});
}
}
代码示例来源:origin: jbruchanov/AnUitor
values.put("LineSpacingExtra", tv.getLineSpacingExtra());
values.put("LineSpacingMultiplier", tv.getLineSpacingMultiplier());
values.put("MaxLines", tv.getMaxLines());
values.put("ShadowColor", getStringColor(tv.getShadowColor()));
values.put("ShadowDX", tv.getShadowDx());
内容来源于网络,如有侵权,请联系作者删除!