当前位置: 首页>>代码示例>>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;未经允许,请勿转载。