本文整理了Java中android.widget.TextView.getWidth()
方法的一些代码示例,展示了TextView.getWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TextView.getWidth()
方法的具体详情如下:
包路径:android.widget.TextView
类名称:TextView
方法名:getWidth
暂无
代码示例来源:origin: jaydenxiao2016/AndroidFire
public URLImageGetter(TextView textView, String newsBody, int picTotal) {
mTextView = textView;
mPicWidth = mTextView.getWidth();
mNewsBody = newsBody;
mPicTotal = picTotal;
}
代码示例来源:origin: TommyLemon/APIJSON
width = tvTabs[position].getWidth();
if (minWidth < width) {
minWidth = width;
if (tvTabs[i].getWidth() > maxWidth) {
tvTabs[i].setWidth(maxWidth);
代码示例来源:origin: TeamNewPipe/NewPipe
@Override
public void onProgressUpdate(int currentProgress, int duration, int bufferPercent) {
// Set buffer progress
progressSeekBar.setSecondaryProgress((int) (progressSeekBar.getMax() * ((float) bufferPercent / 100)));
// Set Duration
progressSeekBar.setMax(duration);
progressEndTime.setText(Localization.getDurationString(duration / 1000));
// Set current time if not seeking
if (!seeking) {
progressSeekBar.setProgress(currentProgress);
progressCurrentTime.setText(Localization.getDurationString(currentProgress / 1000));
}
if (player != null) {
progressLiveSync.setClickable(!player.isLiveEdge());
}
// this will make shure progressCurrentTime has the same width as progressEndTime
final ViewGroup.LayoutParams endTimeParams = progressEndTime.getLayoutParams();
final ViewGroup.LayoutParams currentTimeParams = progressCurrentTime.getLayoutParams();
currentTimeParams.width = progressEndTime.getWidth();
progressCurrentTime.setLayoutParams(currentTimeParams);
}
代码示例来源:origin: TommyLemon/Android-ZBLibrary
width = tvTabs[position].getWidth();
if (minWidth < width) {
minWidth = width;
if (tvTabs[i].getWidth() > maxWidth) {
tvTabs[i].setWidth(maxWidth);
代码示例来源:origin: grantland/android-autofittextview
int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
if (targetWidth <= 0) {
return;
代码示例来源:origin: kaku2015/ColorfulNews
public URLImageGetter(TextView textView, String newsBody, int picTotal) {
mTextView = textView;
mPicWidth = mTextView.getWidth();
mNewsBody = newsBody;
mPicTotal = picTotal;
}
代码示例来源:origin: stackoverflow.com
mTextView.getWidth(),
mTextView.getHeight(),
mTextView.getPaint(),
代码示例来源:origin: stackoverflow.com
final TextView tv = (TextView) findViewById(R.id.myTextView);
ViewTreeObserver vto = tv.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
Toast.makeText(MyActivity.this, tv.getWidth() + " x " + tv.getHeight(), Toast.LENGTH_LONG).show();
tv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
}
});
代码示例来源:origin: willowtreeapps/Hyperion-Android
canvas.translate(rectPrimary.centerX() - (measurementWidthText.getWidth() / 2),
rectPrimary.top - measurementWidthText.getHeight() - measurementTextOffset);
measurementWidthText.draw(canvas);
if (measurementHeightText != null) {
canvas.save();
canvas.translate(rectSecondary.centerX() - measurementHeightText.getWidth() / 2,
(rectPrimary.bottom + rectSecondary.top) / 2 - (measurementHeightText.getHeight() / 2));
measurementHeightText.draw(canvas);
if (measurementWidthText != null) {
canvas.save();
canvas.translate((rectPrimary.right + rectSecondary.left) / 2 - (measurementWidthText.getWidth() / 2),
rectSecondary.centerY() - measurementWidthText.getHeight() / 2);
measurementWidthText.draw(canvas);
if (measurementHeightText != null) {
canvas.save();
canvas.translate(rectSecondary.centerX() - measurementHeightText.getWidth() / 2,
(rectPrimary.top + rectSecondary.bottom) / 2 - (measurementHeightText.getHeight() / 2));
measurementHeightText.draw(canvas);
if (measurementWidthText != null) {
canvas.save();
canvas.translate((rectPrimary.left + rectSecondary.right) / 2 - (measurementWidthText.getWidth() / 2),
rectSecondary.centerY() - measurementWidthText.getHeight() / 2);
measurementWidthText.draw(canvas);
if (measurementLeftText != null) {
代码示例来源:origin: stackoverflow.com
int width = tv.getWidth() - tv.getPaddingLeft() - tv.getPaddingRight();
if(width == 0)
代码示例来源:origin: GcsSloop/diycode
float height;
Logger.i("Image width is " + resource.getIntrinsicWidth());
Logger.i("View width is " + view.getWidth());
if (resource.getIntrinsicWidth() >= getView().getWidth()) {
float downScale = (float) resource.getIntrinsicWidth() / getView().getWidth();
width = (float) resource.getIntrinsicWidth() / (float) downScale;
height = (float) resource.getIntrinsicHeight() / (float) downScale;
} else {
float multiplier = (float) getView().getWidth() / resource.getIntrinsicWidth();
width = (float) resource.getIntrinsicWidth() * (float) multiplier;
height = (float) resource.getIntrinsicHeight() * (float) multiplier;
代码示例来源:origin: iZeroer/Daily
public URLImageGetter(TextView textView, String newsBody, int picTotal) {
mTextView = textView;
mPicWidth = mTextView.getWidth();
mNewsBody = newsBody;
mPicTotal = picTotal;
}
代码示例来源:origin: stackoverflow.com
TextView tv1 = (TextView) findViewById(R.id.text1);
TextView tv2 = (TextView) findViewById(R.id.text2);
if(tv1.getWidth() < tv2.getWidth())
tv1.setWidth(tv2.getWidth());
else
tv2.setWidth(tv1.getWidth());
代码示例来源:origin: stackoverflow.com
View container = findViewById(R.id.container);
TextView tv1 = (TextView) findViewById(R.id.text1);
TextView tv2 = (TextView) findViewById(R.id.text2);
String HEADER = tv1.getText();
String COUNT = tv2.getText();
int widthHeader = tv1.getWidth();
int widthCount = tv1.getWidth();
int widthAvailable = container.getWidth();
if (widthAvailable - widthHeader > widthCount) {
tv1.setText(HEADER + " - " + COUNT);
tv2.setText("");
}
代码示例来源:origin: Yuphee/GoogleTotpAuth
public TextRunnable(TextView textView,char rotateText) {
this.number = textView;
this.rotateText = rotateText;
cX = textView.getWidth() / 2.0f;
cY = textView.getHeight() / 2.0f;
enableRefresh = true;
}
代码示例来源:origin: stackoverflow.com
TextView a = getViewById(R.id.textview);
TextPaint paint = a.getPaint();
Rect rect = new Rect();
String text = String.valueOf(a.getText());
paint.getTextBounds(text, 0, text.length(), rect);
if(rect.height() > a.getHeight() || rect.getWidth() > a.getWidth()) {
Log.i("TEST", "Your text is too large");
}
代码示例来源:origin: stackoverflow.com
float in[] = new float[] {0f,1f};
TextView textView= (TextView)findViewById(R.id.tv_test);
Shader shader = new LinearGradient(
0, textView.getTextSize(), textView.getWidth(), textView.getHeight(), new int[]{Color.RED, Color.BLUE},in,
Shader.TileMode.CLAMP);
textView.getPaint().setShader(shader);
代码示例来源:origin: googlesamples/android-unsplash
private static void setTextViewData(TextView view, TextResizeData data, float fontSize) {
view.setTextSize(TypedValue.COMPLEX_UNIT_PX, fontSize);
view.setPadding(data.paddingLeft, data.paddingTop, data.paddingRight, data.paddingBottom);
view.setRight(view.getLeft() + data.width);
view.setBottom(view.getTop() + data.height);
view.setTextColor(data.textColor);
int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY);
int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY);
view.measure(widthSpec, heightSpec);
view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom());
}
代码示例来源:origin: DroidsOnRoids/Workcation
public TextResizeData(TextView textView) {
this.paddingLeft = textView.getPaddingLeft();
this.paddingTop = textView.getPaddingTop();
this.paddingRight = textView.getPaddingRight();
this.paddingBottom = textView.getPaddingBottom();
this.width = textView.getWidth();
this.height = textView.getHeight();
this.gravity = textView.getGravity();
this.textColor = textView.getCurrentTextColor();
}
}
代码示例来源:origin: googlesamples/android-unsplash
public TextResizeData(TextView textView) {
this.paddingLeft = textView.getPaddingLeft();
this.paddingTop = textView.getPaddingTop();
this.paddingRight = textView.getPaddingRight();
this.paddingBottom = textView.getPaddingBottom();
this.width = textView.getWidth();
this.height = textView.getHeight();
this.gravity = textView.getGravity();
this.textColor = textView.getCurrentTextColor();
}
}
内容来源于网络,如有侵权,请联系作者删除!