本文整理汇总了Java中android.widget.TextView.setMinimumHeight方法的典型用法代码示例。如果您正苦于以下问题:Java TextView.setMinimumHeight方法的具体用法?Java TextView.setMinimumHeight怎么用?Java TextView.setMinimumHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.TextView
的用法示例。
在下文中一共展示了TextView.setMinimumHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: show
import android.widget.TextView; //导入方法依赖的package包/类
public static void show(Context context, int color, CharSequence string, int duration) {
if(context == null) return;
DisplayMetrics dm = context.getResources().getDisplayMetrics();
float density = dm.density;
Toast toast = new Toast(context);
toast.setDuration(duration);
toast.setGravity(Gravity.TOP, 0, (int) (48 * density));
FrameLayout frame = new FrameLayout(context);
frame.setPadding(0, 0, 0, 0);
int width = dm.widthPixels;
FrameLayout.LayoutParams params =
new FrameLayout.LayoutParams(width, FrameLayout.LayoutParams.WRAP_CONTENT);
TextView text = new TextView(context);
text.setMinimumHeight((int) (28 * density));
text.setGravity(Gravity.CENTER);
text.setTextColor(Color.WHITE);
text.setTextSize(14);
frame.addView(text, params);
toast.setView(frame);
text.setBackgroundColor(color);
text.setText(string);
toast.show();
}
示例2: createListItem
import android.widget.TextView; //导入方法依赖的package包/类
public TextView createListItem() {
TextView view = new TextView(mContext);
view.setFadingEdgeLength(mFadeEdgeLength);
view.setHorizontalFadingEdgeEnabled(true);
view.setSingleLine();
view.setTextSize(TEXT_SIZE_SP);
view.setMinimumHeight(mListItemHeight);
view.setGravity(Gravity.CENTER_VERTICAL);
view.setCompoundDrawablePadding(mPadding);
if (!mIsLayoutDirectionRTL) {
view.setPadding(mPadding, 0, mPadding + mFadePadding , 0);
} else {
view.setPadding(mPadding + mFadePadding, 0, mPadding, 0);
}
return view;
}
示例3: createLabel
import android.widget.TextView; //导入方法依赖的package包/类
private TextView createLabel(GridLayout parent, int rowIndex, boolean optionIconExists,
boolean editIconExists, boolean isEnabled) {
Context context = parent.getContext();
Resources resources = context.getResources();
// By default, the label appears to the right of the "button" in the second column.
// + If there is no button, no option and edit icon, the label spans the whole row.
// + If there is no option and edit icon, the label spans three columns.
// + If there is no edit icon or option icon, the label spans two columns.
// + Otherwise, the label occupies only its own column.
int columnStart = 1;
int columnSpan = 1;
if (!optionIconExists) columnSpan++;
if (!editIconExists) columnSpan++;
TextView labelView = new TextView(context);
if (mRowType == OPTION_ROW_TYPE_OPTION) {
// Show the string representing the PaymentOption.
ApiCompatibilityUtils.setTextAppearance(labelView, isEnabled
? R.style.PaymentsUiSectionDefaultText
: R.style.PaymentsUiSectionDisabledText);
labelView.setText(convertOptionToString(
mOption, mDelegate.isBoldLabelNeeded(OptionSection.this)));
labelView.setEnabled(isEnabled);
} else if (mRowType == OPTION_ROW_TYPE_ADD) {
// Shows string saying that the user can add a new option, e.g. credit card no.
String typeface = resources.getString(R.string.roboto_medium_typeface);
int textStyle = resources.getInteger(R.integer.roboto_medium_textstyle);
int buttonHeight = resources.getDimensionPixelSize(
R.dimen.payments_section_add_button_height);
ApiCompatibilityUtils.setTextAppearance(
labelView, R.style.PaymentsUiSectionAddButtonLabel);
labelView.setMinimumHeight(buttonHeight);
labelView.setGravity(Gravity.CENTER_VERTICAL);
labelView.setTypeface(Typeface.create(typeface, textStyle));
} else if (mRowType == OPTION_ROW_TYPE_DESCRIPTION) {
// The description spans all the columns.
columnStart = 0;
columnSpan = 4;
ApiCompatibilityUtils.setTextAppearance(
labelView, R.style.PaymentsUiSectionDescriptiveText);
} else if (mRowType == OPTION_ROW_TYPE_WARNING) {
// Warnings use three columns.
columnSpan = 3;
ApiCompatibilityUtils.setTextAppearance(
labelView, R.style.PaymentsUiSectionWarningText);
}
// The label spans two columns if no option or edit icon, or spans three columns if
// no option and edit icons. Setting the view width to 0 forces it to stretch.
GridLayout.LayoutParams labelParams = new GridLayout.LayoutParams(
GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
GridLayout.spec(columnStart, columnSpan, GridLayout.FILL));
labelParams.topMargin = mVerticalMargin;
labelParams.width = 0;
if (optionIconExists) {
// Margin at the end of the label instead of the start of the option icon to
// allow option icon in the the next row align with the end of label (include
// end margin) when edit icon exits in that row, like below:
// ---Label---------------------[label margin]|---option icon---|
// ---Label---[label margin]|---option icon---|----edit icon----|
ApiCompatibilityUtils.setMarginEnd(labelParams, mLargeSpacing);
}
parent.addView(labelView, labelParams);
labelView.setOnClickListener(OptionSection.this);
return labelView;
}
示例4: setSheetItems
import android.widget.TextView; //导入方法依赖的package包/类
/**
* 生成条目
*/
private void setSheetItems() {
if (listSheetItem == null || listSheetItem.size() <= 0) {
return;
}
lLayoutItem.setGravity(STYLE == STYLE_WEI_XIN ? Gravity.LEFT | Gravity.CENTER_VERTICAL : Gravity.CENTER);
lLayoutItem.removeAllViews();
// 循环添加条目
for (int i = 0; i <= listSheetItem.size() - 1; i++) {
final int item = i;
SheetItem sheetItem = listSheetItem.get(i);
final OnSheetItemListener listener = sheetItem.itemClickListener;
View view = new View(context);
TextView textView = new TextView(context);
textView.setText(sheetItem.name);
textView.setTextSize(unitItems, textSizeItems);
textView.setGravity(STYLE == STYLE_WEI_XIN ? Gravity.LEFT | Gravity.CENTER_VERTICAL : Gravity.CENTER);
textView.setPadding(dip2px(mPaddingLeft), dip2px(mPaddingTop), dip2px(mPaddingLeft), dip2px(mPaddingTop));
vLineTitle.setVisibility(showTitle && STYLE == STYLE_NORMAL ? View.VISIBLE : View.GONE);
// 背景图片
if (STYLE == STYLE_IOS) {
if (listSheetItem.size() == 1) {
if (showTitle) {
textView.setBackgroundResource(R.drawable.action_sheet_bottom);
} else {
textView.setBackgroundResource(R.drawable.action_sheet_single);
}
} else {
if (showTitle) {
if (i >= 0 && i < listSheetItem.size() - 1) {
textView.setBackgroundResource(R.drawable.action_sheet_middle);
} else {
textView.setBackgroundResource(R.drawable.action_sheet_bottom);
}
} else {
if (i == 0) {
textView.setBackgroundResource(R.drawable.action_sheet_top);
} else if (i < listSheetItem.size() - 1) {
textView.setBackgroundResource(R.drawable.action_sheet_middle);
} else {
textView.setBackgroundResource(R.drawable.action_sheet_bottom);
}
}
}
} else {
textView.setBackgroundResource(R.drawable.action_sheet_edge);
tvCancel.setBackgroundResource(R.drawable.action_sheet_edge);
tvTitle.setBackgroundResource(R.color.colorActionSheetEdge);
view.setBackgroundResource(R.color.colorActionSheetEdgeLineGray);
}
// 字体颜色
textView.setTextColor(sheetItem.color);
LinearLayout.LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
// 高度
textView.setLayoutParams(params);
textView.setMinimumHeight(getItemHeight());
tvTitle.setMinimumHeight(STYLE != STYLE_IOS ? getItemHeight() : dip2px(20));
textView.setLineSpacing(mLineSpacingExtra, mLineSpacingMultiplier);
// 点击事件
textView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onClick(item);
}
dialog.dismiss();
}
});
lLayoutItem.addView(textView);
if (STYLE == STYLE_NORMAL) {
view.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, (int) context.getResources().getDimension(R.dimen.dp_line_size)));
lLayoutItem.addView(view);
}
}
}