本文整理匯總了Java中android.widget.Button.setMinHeight方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setMinHeight方法的具體用法?Java Button.setMinHeight怎麽用?Java Button.setMinHeight使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.Button
的用法示例。
在下文中一共展示了Button.setMinHeight方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: generateTopBarTextButton
import android.widget.Button; //導入方法依賴的package包/類
/**
* 生成一個文本按鈕,並設置文字
*
* @param text 按鈕的文字
* @return
*/
private Button generateTopBarTextButton(String text) {
Button button = new Button(getContext());
button.setBackgroundResource(0);
button.setMinWidth(0);
button.setMinHeight(0);
button.setMinimumWidth(0);
button.setMinimumHeight(0);
int paddingHorizontal = getTopBarTextBtnPaddingHorizontal();
button.setPadding(paddingHorizontal, 0, paddingHorizontal, 0);
button.setTextColor(QMUIResHelper.getAttrColorStateList(getContext(), R.attr.qmui_topbar_text_btn_color_state_list));
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_topbar_text_btn_text_size));
button.setGravity(Gravity.CENTER);
button.setText(text);
return button;
}
示例2: generateSpanActionButton
import android.widget.Button; //導入方法依賴的package包/類
/**
* 生成適用於對話框的按鈕
*/
public static Button generateSpanActionButton(Context context, String text, int iconRes, boolean hasLeftMargin) {
Button button = new Button(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_height));
if(hasLeftMargin){
lp.leftMargin = QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_margin_left);
}
button.setLayoutParams(lp);
button.setMinHeight(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_height));
button.setMinWidth(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_min_width));
button.setMinimumWidth(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_min_width));
button.setMinimumHeight(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_height));
button.setText(text);
if (iconRes != 0) {
Drawable drawable = context.getResources().getDrawable(iconRes);
if (drawable != null) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
button.setCompoundDrawables(drawable, null, null, null);
button.setCompoundDrawablePadding(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_drawable_padding));
}
}
button.setGravity(Gravity.CENTER);
button.setClickable(true);
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_text_size));
button.setTextColor(QMUIResHelper.getAttrColorStateList(context, R.attr.qmui_dialog_action_text_color));
button.setBackground(QMUIResHelper.getAttrDrawable(context, R.attr.qmui_dialog_action_btn_bg));
final int paddingHor = QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_padding_horizontal);
button.setPadding(paddingHor, 0, paddingHor, 0);
return button;
}
示例3: generateSpanActionButton
import android.widget.Button; //導入方法依賴的package包/類
/**
* 生成適用於對話框的按鈕
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public static Button generateSpanActionButton(Context context, String text, int iconRes, boolean hasLeftMargin) {
Button button = new Button(context);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT,
QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_height));
if(hasLeftMargin){
lp.leftMargin = QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_margin_left);
}
button.setLayoutParams(lp);
button.setMinHeight(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_height));
button.setMinWidth(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_min_width));
button.setMinimumWidth(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_min_width));
button.setMinimumHeight(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_height));
button.setText(text);
if (iconRes != 0) {
Drawable drawable = ContextCompat.getDrawable(context, iconRes);
if (drawable != null) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
button.setCompoundDrawables(drawable, null, null, null);
button.setCompoundDrawablePadding(QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_drawable_padding));
}
}
button.setGravity(Gravity.CENTER);
button.setClickable(true);
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_text_size));
button.setTextColor(QMUIResHelper.getAttrColorStateList(context, R.attr.qmui_dialog_action_text_color));
button.setBackground(QMUIResHelper.getAttrDrawable(context, R.attr.qmui_dialog_action_btn_bg));
final int paddingHor = QMUIResHelper.getAttrDimen(context, R.attr.qmui_dialog_action_button_padding_horizontal);
button.setPadding(paddingHor, 0, paddingHor, 0);
return button;
}
示例4: generateTopBarTextButton
import android.widget.Button; //導入方法依賴的package包/類
/**
* 生成一個文本按鈕,並設置文字
*
* @param text 按鈕的文字
* @return 返回生成的按鈕
*/
private Button generateTopBarTextButton(String text) {
Button button = new Button(getContext());
button.setBackgroundResource(0);
button.setMinWidth(0);
button.setMinHeight(0);
button.setMinimumWidth(0);
button.setMinimumHeight(0);
button.setPadding(mTopBarTextBtnPaddingHor, 0, mTopBarTextBtnPaddingHor, 0);
button.setTextColor(mTopBarTextBtnTextColor);
button.setTextSize(TypedValue.COMPLEX_UNIT_PX, mTopBarTextBtnTextSize);
button.setGravity(Gravity.CENTER);
button.setText(text);
return button;
}
示例5: init
import android.widget.Button; //導入方法依賴的package包/類
private void init(String text, int iconRes) {
LinearLayout.LayoutParams parentLp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_action_block_btn_height));
setLayoutParams(parentLp);
setBackground(QMUIResHelper.getAttrDrawable(getContext(), R.attr.qmui_dialog_action_block_btn_bg));
setPadding(
QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_padding_horizontal),
0,
QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_padding_horizontal),
0
);
mButton = new Button(getContext());
mButton.setBackgroundResource(0);
mButton.setPadding(0, 0, 0, 0);
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
lp.gravity = Gravity.RIGHT;
mButton.setLayoutParams(lp);
mButton.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
mButton.setText(text);
if (iconRes != 0) {
Drawable drawable = ContextCompat.getDrawable(getContext(), iconRes);
if (drawable != null) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mButton.setCompoundDrawables(drawable, null, null, null);
mButton.setCompoundDrawablePadding(QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_action_drawable_padding));
}
}
mButton.setMinHeight(0);
mButton.setMinWidth(0);
mButton.setMinimumWidth(0);
mButton.setMinimumHeight(0);
mButton.setClickable(false);
mButton.setDuplicateParentStateEnabled(true);
mButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_action_button_text_size));
mButton.setTextColor(QMUIResHelper.getAttrColorStateList(getContext(), R.attr.qmui_dialog_action_text_color));
addView(mButton);
}
示例6: init
import android.widget.Button; //導入方法依賴的package包/類
private void init(String text, int iconRes) {
LinearLayout.LayoutParams parentLp = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_action_block_btn_height));
setLayoutParams(parentLp);
QMUIViewHelper.setBackgroundKeepingPadding(this, QMUIResHelper.getAttrDrawable(getContext(), R.attr.qmui_dialog_action_block_btn_bg));
setPadding(
QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_padding_horizontal),
0,
QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_padding_horizontal),
0
);
mButton = new Button(getContext());
mButton.setBackgroundResource(0);
mButton.setPadding(0, 0, 0, 0);
LayoutParams lp = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
lp.gravity = Gravity.RIGHT;
mButton.setLayoutParams(lp);
mButton.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL);
mButton.setText(text);
if (iconRes != 0) {
Drawable drawable = ContextCompat.getDrawable(getContext(), iconRes);
if (drawable != null) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
mButton.setCompoundDrawables(drawable, null, null, null);
mButton.setCompoundDrawablePadding(QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_action_drawable_padding));
}
}
mButton.setMinHeight(0);
mButton.setMinWidth(0);
mButton.setMinimumWidth(0);
mButton.setMinimumHeight(0);
mButton.setClickable(false);
mButton.setDuplicateParentStateEnabled(true);
mButton.setTextSize(TypedValue.COMPLEX_UNIT_PX, QMUIResHelper.getAttrDimen(getContext(), R.attr.qmui_dialog_action_button_text_size));
mButton.setTextColor(QMUIResHelper.getAttrColorStateList(getContext(), R.attr.qmui_dialog_action_text_color));
addView(mButton);
}