當前位置: 首頁>>代碼示例>>Java>>正文


Java Button.setLayoutParams方法代碼示例

本文整理匯總了Java中android.widget.Button.setLayoutParams方法的典型用法代碼示例。如果您正苦於以下問題:Java Button.setLayoutParams方法的具體用法?Java Button.setLayoutParams怎麽用?Java Button.setLayoutParams使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.Button的用法示例。


在下文中一共展示了Button.setLayoutParams方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getButton

import android.widget.Button; //導入方法依賴的package包/類
private Button getButton(String text, int position) {

        // 動態生成選擇按鈕
        final Button button = new Button(mContext);
        button.setText(text);
        button.setTag(position);
        button.setTextColor(mBuilder.getItemTextColor());
        button.setTextSize(mBuilder.getItemTextSize());
        button.setLayoutParams(new LinearLayout.LayoutParams(AbsListView.LayoutParams
                .MATCH_PARENT, mBuilder.getItemHeight()));
        button.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {

                if (mBuilder.getOnItemListener() != null) {

                    selectPosition = Integer.parseInt(button.getTag().toString());
                    mBuilder.getOnItemListener().onItemClick(button, selectPosition);

                }
            }
        });

        return button;
    }
 
開發者ID:wp521,項目名稱:MyFire,代碼行數:27,代碼來源:NormalSelectionDialog.java

示例2: setPositiveButton

import android.widget.Button; //導入方法依賴的package包/類
/**
        * set positive button
        *
        * @param text the name of button
        */
       public void setPositiveButton(String text, final View.OnClickListener listener)
{
           Button button = new Button(mContext);
           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
	LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
           button.setLayoutParams(params);
           button.setBackgroundResource(R.drawable.material_card);
           button.setTextColor(Color.argb(255, 35, 159, 242));
           button.setText(text);
           button.setGravity(Gravity.CENTER);
           button.setTextSize(14);
           button.setPadding(dip2px(12), 0, dip2px(32), dip2px(BUTTON_BOTTOM));
           button.setOnClickListener(listener);
           mButtonLayout.addView(button);
       }
 
開發者ID:stytooldex,項目名稱:pius1,代碼行數:21,代碼來源:MaterialDialog.java

示例3: setNegativeButton

import android.widget.Button; //導入方法依賴的package包/類
/**
        * set negative button
        *
        * @param text the name of button
        */
       public void setNegativeButton(String text, final View.OnClickListener listener)
{
           Button button = new Button(mContext);
           LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
	LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
           button.setLayoutParams(params);
           button.setBackgroundResource(R.drawable.material_card);
           button.setText(text);
           button.setTextColor(Color.argb(222, 0, 0, 0));
           button.setTextSize(14);
           button.setGravity(Gravity.CENTER);
           button.setPadding(0, 0, 0, dip2px(8));
           button.setOnClickListener(listener);
           if (mButtonLayout.getChildCount() > 0)
    {
               params.setMargins(20, 0, 10, dip2px(BUTTON_BOTTOM));
               button.setLayoutParams(params);
               mButtonLayout.addView(button, 1);
           }
    else
    {
               button.setLayoutParams(params);
               mButtonLayout.addView(button);
           }
       }
 
開發者ID:stytooldex,項目名稱:pius1,代碼行數:31,代碼來源:MaterialDialog.java

示例4: addBtn

import android.widget.Button; //導入方法依賴的package包/類
public BottomPopMenu addBtn(String btnTxt, final int i){
    Button button = new Button(mContext);
    buttonMap.put(i, button);
    button.setOnClickListener(v -> {
        dismiss();
        for (OnBtnClickListener btnClickListener : onBtnClickListener) {
            btnClickListener.onBtnClick(i);
        }
    });
    button.setBackgroundResource(R.drawable.umi_bg_corners_solid);
    button.setLayoutParams(lp);
    button.setText(btnTxt);
    button.setTextColor(Color.WHITE);
    btnLayout.addView(button);
    return this;
}
 
開發者ID:Lazyeraser,項目名稱:DereHelper,代碼行數:17,代碼來源:BottomPopMenu.java

示例5: createSpecimenDetailsButton

import android.widget.Button; //導入方法依賴的package包/類
private void createSpecimenDetailsButton() {
    int margin = UiUtils.dipToPixels(getActivity(), 10);

    Button button = new Button(getActivity());
    LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.setMargins(margin, margin, margin, margin);
    button.setLayoutParams(params);
    button.setBackgroundResource(R.drawable.button);
    button.setText(R.string.specimen_details);
    mViewContainer.addView(button);

    button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(getActivity(), SrvaSpecimenActivity.class);
            intent.putExtra(SrvaSpecimenActivity.EXTRA_SRVA_EVENT, mSrvaEvent);
            intent.putExtra(SrvaSpecimenActivity.EXTRA_EDIT_MODE, isEditModeOn());
            startActivityForResult(intent, SPECIMEN_REQUEST_CODE);
        }
    });
}
 
開發者ID:suomenriistakeskus,項目名稱:oma-riista-android,代碼行數:22,代碼來源:SrvaEditFragment.java

示例6: refreshWordSelector

import android.widget.Button; //導入方法依賴的package包/類
public void refreshWordSelector()	{
LinkedList<String> listMatched = minputMethodCaller.matchFuncVars(mstrBuffered);
	mwordSelectionContainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, mnInputBtnHeight));		
mlLayoutWordSelectionBtnHolder.removeAllViews();
for (int idx = 0 ; idx < listMatched.size(); idx ++)	{
	String str = listMatched.get(idx);
	Button btn = new Button(getContext());
	btn.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, mnInputBtnHeight));
	btn.setTag(str);
	btn.setText(str);
	btn.setTextSize(TypedValue.COMPLEX_UNIT_PX, mfTextSize);
	int nTextColor = Color.RED;
	if (idx > 0)	{
		nTextColor = Color.GREEN;
	}
	btn.setTextColor(nTextColor);
	btn.setBackgroundResource(R.drawable.btn_background);
	btn.setOnClickListener(new OnClickListener()	{

		@Override
		public void onClick(View v) {
			minputMethodCaller.onClickSelectedWord((String)v.getTag());
		}
		
	});
	mlLayoutWordSelectionBtnHolder.addView(btn);
}	
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:29,代碼來源:AMInputMethod.java

示例7: addAButton

import android.widget.Button; //導入方法依賴的package包/類
private void addAButton(final String text) {
    int dimension = (int) PixelDipConverter.convertDpToPixel(50, getContext());
    //int padding = (int) PixelDipConverter.convertDpToPixel(10, getContext());
    final Button name = new Button(getContext());

    name.setLayoutParams(new LinearLayout.LayoutParams(dimension, dimension));


    name.setGravity(Gravity.CENTER);

    name.setText(text);
    name.setTextSize(15);
    name.setAllCaps(true);

    //name.setPadding(padding, padding, padding, padding);

    name.setClickable(true);

    name.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            iAccessoryView.onButtonAccessoryViewClicked(text);
        }
    });

    name.setBackgroundResource(outValue.resourceId);
    addView(name);
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:29,代碼來源:AccessoryView.java

示例8: 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;
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:36,代碼來源:QMUIDialogAction.java

示例9: getView

import android.widget.Button; //導入方法依賴的package包/類
@Override
public View getView(final int i, final View view, ViewGroup viewGroup) {
    final Button img = new Button(context);
    int width = ScreenUtils.getScreenWidth(context) - DensityUtils.dp2px(context, 45);// 獲取屏幕寬度
    int height = 0;
    width = width / 5;// 對當前的列數進行設置imgView的寬度
    height = width * 5 / 6;
    if (!weeklist[i]) {
        img.setBackgroundResource(R.color.new_grty);
    } else {
        img.setBackgroundResource(R.color.colorPrimary);
    }
    img.setText(String.valueOf(i + 1));
    img.setTextColor(Color.WHITE);
    AbsListView.LayoutParams layout = new AbsListView.LayoutParams(width, height);
    img.setLayoutParams(layout);

    img.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (onItemClickListener != null) {
                onItemClickListener.onItemClick(v, i, view.getId());
            }
        }
    });
    return img;
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:28,代碼來源:SyllabusItemAdapter.java

示例10: getView

import android.widget.Button; //導入方法依賴的package包/類
@Override
public View getView(final int position, final View convertView, ViewGroup parent) {
    final Button img = new Button(context);
    int width = ScreenUtils.getScreenWidth(context) - DensityUtils.dp2px(context, 45);// 獲取屏幕寬度
    int height = 0;
    width = width / 5;// 對當前的列數進行設置imgView的寬度
    height = width * 5 / 6;
    if (!weeklist[position]) {
        img.setBackgroundResource(R.color.new_grty);
    } else {
        img.setBackgroundResource(R.color.colorPrimary);
    }
    img.setText(String.valueOf(position + 1));
    img.setTextColor(Color.WHITE);
    AbsListView.LayoutParams layout = new AbsListView.LayoutParams(width, height);
    img.setLayoutParams(layout);
    img.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (type == SHOW_COURSE)
                return;
            if (weeklist[position]) {
                img.setBackgroundResource(R.color.new_grty);
                weeklist[position] = false;
            } else if (!weeklist[position]) {
                img.setBackgroundResource(R.color.colorPrimary);
                weeklist[position] = true;
            }
        }
    });
    return img;
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:33,代碼來源:SyllabusItemActivity.java

示例11: viewForEmptyDataSet

import android.widget.Button; //導入方法依賴的package包/類
@Override
    public Button viewForEmptyDataSet(RelativeLayout layout,PHEmptyDataSet.TapNoDataType type) {
        Button btn = new Button(this);

        btn.setLayoutParams(new ViewGroup.LayoutParams(200,200));
//        Bitmap bitmap = BitmapFactory.decodeResource(res,R.drawable.m123);
        Drawable draw = new BitmapDrawable(getResources(),BitmapFactory.decodeResource(getResources(),R.drawable.m123));
        btn.setBackground(draw);
        btn.setText("goog");
        btn.setTextColor(Color.RED);
        btn.setTextSize((float)8.0);
        return btn;
    }
 
開發者ID:HeterPu,項目名稱:PHEmptyDataSetForAndroid,代碼行數:14,代碼來源:MainActivity.java

示例12: create

import android.widget.Button; //導入方法依賴的package包/類
public static RelativeLayout create(Context context) {
	SizeHelper.prepare(context);

	RelativeLayout root = new RelativeLayout(context);
	root.setId(ResHelper.getIdRes(context, "rl_lv_item_bg"));
	AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(95));
	root.setLayoutParams(params);
	int padding = SizeHelper.fromPxWidth(14);
	root.setPadding(padding, padding, padding, padding);
	root.setGravity(Gravity.CENTER_VERTICAL);
	root.setBackgroundColor(0xffffffff);

	AsyncImageView contactImage = new AsyncImageView(context);
	contactImage.setId(ResHelper.getIdRes(context, "iv_contact"));
	RelativeLayout.LayoutParams contactImageParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(64),
			SizeHelper.fromPxWidth(64));
	contactImageParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	contactImage.setLayoutParams(contactImageParams);
	contactImage.setScaleType(ScaleType.FIT_CENTER);
	root.addView(contactImage);

	LinearLayout wrapper = new LinearLayout(context);
	RelativeLayout.LayoutParams wrapperParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT,
			RelativeLayout.LayoutParams.WRAP_CONTENT);
	wrapperParams.addRule(RelativeLayout.RIGHT_OF, ResHelper.getIdRes(context, "iv_contact"));
	wrapperParams.addRule(RelativeLayout.CENTER_VERTICAL);
	wrapperParams.leftMargin = SizeHelper.fromPxWidth(12);
	wrapper.setLayoutParams(wrapperParams);
	wrapper.setOrientation(LinearLayout.VERTICAL);
	root.addView(wrapper);

	TextView name = new TextView(context);
	name.setId(ResHelper.getIdRes(context, "tv_name"));
	LinearLayout.LayoutParams nameParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	name.setLayoutParams(nameParams);
	name.setTextColor(0xff333333);
	name.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(28));
	wrapper.addView(name);

	TextView contact = new TextView(context);
	contact.setId(ResHelper.getIdRes(context, "tv_contact"));
	LinearLayout.LayoutParams contactParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	contact.setLayoutParams(contactParams);
	contact.setTextColor(0xff999999);
	contact.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	wrapper.addView(contact);

	Button add = new Button(context);
	add.setId(ResHelper.getIdRes(context, "btn_add"));
	RelativeLayout.LayoutParams addParams = new RelativeLayout.LayoutParams(SizeHelper.fromPxWidth(92),
			SizeHelper.fromPxWidth(46));
	addParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
	addParams.addRule(RelativeLayout.CENTER_VERTICAL);
	add.setLayoutParams(addParams);
	int resid = ResHelper.getStringRes(context, "smssdk_add_contact");
	add.setText(resid);
	add.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(22));
	add.setTextColor(0xff797979);
	//resid = R.getBitmapRes(context, "smssdk_corners_bg");
	add.setBackgroundDrawable(DrawableHelper.createCornerBg(context));
	add.setPadding(0, 0, 0, 0);
	root.addView(add);

	return root;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:69,代碼來源:ContactsListviewItemLayout.java

示例13: initPageView

import android.widget.Button; //導入方法依賴的package包/類
private void initPageView() {
	flPage = new FrameLayout(getContext());
	flPage.setOnClickListener(this);
	flPage.setBackgroundDrawable(new ColorDrawable(0x55000000));

	// container of the platform gridview
	llPage = new LinearLayout(getContext()) {
		public boolean onTouchEvent(MotionEvent event) {
			return true;
		}
	};
	llPage.setOrientation(LinearLayout.VERTICAL);
	llPage.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	FrameLayout.LayoutParams lpLl = new FrameLayout.LayoutParams(
			FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT);
	lpLl.gravity = Gravity.BOTTOM;
	llPage.setLayoutParams(lpLl);
	flPage.addView(llPage);

	// gridview
	grid = new PlatformGridView(getContext());
	grid.setEditPageBackground(getBackgroundView());
	LinearLayout.LayoutParams lpWg = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	grid.setLayoutParams(lpWg);
	llPage.addView(grid);

	// cancel button
	btnCancel = new Button(getContext());
	btnCancel.setTextColor(0xff3a65ff);
	btnCancel.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 20);
	int resId = getStringRes(getContext(), "cancel");
	if (resId > 0) {
		btnCancel.setText(resId);
	}
	btnCancel.setPadding(0, 0, 0, com.mob.tools.utils.R.dipToPx(getContext(), 5));

	resId = getBitmapRes(getContext(), "classic_platform_corners_bg");
	if(resId > 0){
		btnCancel.setBackgroundResource(resId);
	}else {
	    btnCancel.setBackgroundDrawable(new ColorDrawable(0xffffffff));
	}

	LinearLayout.LayoutParams lpBtn = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.MATCH_PARENT, com.mob.tools.utils.R.dipToPx(getContext(), 45));
	int dp_10 = com.mob.tools.utils.R.dipToPx(getContext(), 10);
	lpBtn.setMargins(dp_10, dp_10, dp_10, dp_10);
	btnCancel.setLayoutParams(lpBtn);
	llPage.addView(btnCancel);
}
 
開發者ID:liupengandroid,項目名稱:ywApplication,代碼行數:52,代碼來源:PlatformListPage.java

示例14: 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);
}
 
開發者ID:coopese,項目名稱:qmui,代碼行數:42,代碼來源:QMUIDialogAction.java

示例15: 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);
}
 
開發者ID:QMUI,項目名稱:QMUI_Android,代碼行數:42,代碼來源:QMUIDialogAction.java


注:本文中的android.widget.Button.setLayoutParams方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。