本文整理匯總了Java中android.widget.TextView.getPaddingBottom方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.getPaddingBottom方法的具體用法?Java TextView.getPaddingBottom怎麽用?Java TextView.getPaddingBottom使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.TextView
的用法示例。
在下文中一共展示了TextView.getPaddingBottom方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onSharedElementStart
import android.widget.TextView; //導入方法依賴的package包/類
@Override
public void onSharedElementStart(List<String> sharedElementNames,
List<View> sharedElements,
List<View> sharedElementSnapshots) {
TextView author = getAuthor();
targetTextSize = author.getTextSize();
targetTextColors = author.getTextColors();
targetPadding = new Rect(author.getPaddingLeft(),
author.getPaddingTop(),
author.getPaddingRight(),
author.getPaddingBottom());
if (IntentUtil.hasAll(intent,
IntentUtil.TEXT_COLOR, IntentUtil.FONT_SIZE, IntentUtil.PADDING)) {
author.setTextColor(intent.getIntExtra(IntentUtil.TEXT_COLOR, Color.BLACK));
float textSize = intent.getFloatExtra(IntentUtil.FONT_SIZE, targetTextSize);
author.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
Rect padding = intent.getParcelableExtra(IntentUtil.PADDING);
author.setPadding(padding.left, padding.top, padding.right, padding.bottom);
}
}
示例2: captureTextBitmap
import android.widget.TextView; //導入方法依賴的package包/類
private static Bitmap captureTextBitmap(TextView textView) {
Drawable background = textView.getBackground();
textView.setBackground(null);
int width = textView.getWidth() - textView.getPaddingLeft() - textView.getPaddingRight();
int height = textView.getHeight() - textView.getPaddingTop() - textView.getPaddingBottom();
if (width == 0 || height == 0) {
return null;
}
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.translate(-textView.getPaddingLeft(), -textView.getPaddingTop());
textView.draw(canvas);
textView.setBackground(background);
return bitmap;
}
示例3: TextResizeData
import android.widget.TextView; //導入方法依賴的package包/類
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();
}
示例4: getRealHeight
import android.widget.TextView; //導入方法依賴的package包/類
private int getRealHeight() {
TextView tv = textViewWeakReference.get();
if (tv == null) {
return 0;
}
return tv.getHeight() - tv.getPaddingTop() - tv.getPaddingBottom();
}
示例5: adjustSize
import android.widget.TextView; //導入方法依賴的package包/類
/**
* 改變外框大小,適應文字
* 如果當前文字隻有一行,則縮到外框適應文字大小
* 如果文字有多行,則寬度不變,縮小高度到適應文字大小
* 文字外框的位置不變
*
* @param view
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static void adjustSize(TextView view) {
if (view != null && view.getLayoutParams() != null) {
/*
//更好的實現方式,但是ios那邊不支持這種方式
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
layoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
view.setLayoutParams(layoutParams);*/
// 廢棄的實現方式,使用WRAP_CONTENT最簡單,且這種方式算出來的width有bug
// @Deprecated
/*int lineCount = Math.min(view.getLineCount(), getMaxLines(view));
int width, height;
if (lineCount > 1) {//多行,寬度不變,改變高度
width = view.getWidth();
height = view.getLineHeight() * lineCount + view.getPaddingTop() + view.getPaddingBottom();
} else {//一行,改變寬度&高度
final Paint paint = view.getPaint();
width = (int) paint.measureText(view.getText().toString()) + view.getPaddingLeft() + view.getPaddingRight();
height = view.getLineHeight() + view.getPaddingTop() + view.getPaddingBottom();
}*/
int lineCount = Math.min(view.getLineCount(), getMaxLines(view));
float width, height;
if (lineCount > 1) {//多行,寬度不變,改變高度
width = view.getWidth();
height = view.getLineHeight() * lineCount + view.getPaddingTop() + view.getPaddingBottom();
} else {//一行,改變寬度&高度
width = view.getPaddingLeft() + Layout.getDesiredWidth(view.getText(), view.getPaint()) + view.getPaddingRight();
height = view.getLineHeight() + view.getPaddingTop() + view.getPaddingBottom();
}
if (view.getLayoutParams() != null) {
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
layoutParams.width = (int) width;
layoutParams.height = (int) height;
view.setLayoutParams(layoutParams);
}
}
}