当前位置: 首页>>代码示例>>Java>>正文


Java Button.setPadding方法代码示例

本文整理汇总了Java中android.widget.Button.setPadding方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setPadding方法的具体用法?Java Button.setPadding怎么用?Java Button.setPadding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.Button的用法示例。


在下文中一共展示了Button.setPadding方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: traversalViewGroup

import android.widget.Button; //导入方法依赖的package包/类
private void traversalViewGroup(ViewGroup viewGroup, List<Button> btnList, List<ImageButton> imageBtnList) {
    for (int i = 0; i < viewGroup.getChildCount(); i++) {

        View v = viewGroup.getChildAt(i);
        if (v instanceof Button) {
            Button btn = (Button) viewGroup.getChildAt(i);
            btn.setPadding(0, 0, 0, 0);
            btnList.add((Button) viewGroup.getChildAt(i));
        }
        if (v instanceof ImageButton) {
            imageBtnList.add((ImageButton) viewGroup.getChildAt(i));
        }
        if (v instanceof ViewGroup) {
            traversalViewGroup((ViewGroup) viewGroup.getChildAt(i), btnList, imageBtnList);
        }
    }
}
 
开发者ID:coderJohnZhang,项目名称:TvSoftKeyboard,代码行数:18,代码来源:GlobalSoftKeyboard.java

示例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);
    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;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:22,代码来源:QMUITopBar.java

示例5: 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());
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams
                .MATCH_PARENT, mBuilder.getItemHeight());
        button.setLayoutParams(lp);
        button.setGravity(Gravity.LEFT|Gravity.CENTER_VERTICAL);
        button.setPadding(UiUtils.dp2px(mContext,10),0,UiUtils.dp2px(mContext,10),0);
        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,代码行数:30,代码来源:MDSelectionDialog.java

示例6: addButton

import android.widget.Button; //导入方法依赖的package包/类
private void addButton(final DemoInfo leaf){
	Button btn = new Button(getActivity());
	btn.setText(leaf.name);
	btn.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	btn.setBackgroundResource(R.drawable.sel_menu3);
	btn.setTextSize(15);
	btn.setPadding(20, 0, 20, 0);
	btn.setTextColor(Color.WHITE);
	btn.setAllCaps(false);


	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, Utils.dip2px(getActivity(), 40));
	lp.gravity = Gravity.CENTER;
	lp.topMargin = Utils.dip2px(getActivity(), 5);
	lp.bottomMargin = Utils.dip2px(getActivity(), 5);
	lp.leftMargin = Utils.dip2px(getActivity(), 5);
	lp.rightMargin = Utils.dip2px(getActivity(), 5);
	ll_root.addView(btn, lp);

	btn.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			if(leaf.onClickListener == null){
				Toast.makeText(getActivity(), "sorry,此功能尚未实现", Toast.LENGTH_SHORT).show();
			}else{
				leaf.onClickListener.onClick(v);
			}
		}
	});

}
 
开发者ID:cowthan,项目名称:ayo-menu,代码行数:33,代码来源:DemoMenuActivityAttacher.java

示例7: 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

示例8: 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;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:37,代码来源:QMUIDialogAction.java

示例9: 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;
}
 
开发者ID:QMUI,项目名称:QMUI_Android,代码行数:21,代码来源:QMUITopBar.java

示例10: create

import android.widget.Button; //导入方法依赖的package包/类
/**验证返回对话框布局*/
public static LinearLayout create(Context context) {
	SizeHelper.prepare(context);

	LinearLayout root = new LinearLayout(context);
	ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
	root.setLayoutParams(params);
	root.setOrientation(LinearLayout.VERTICAL);

	TextView dialogHint = new TextView(context);
	dialogHint.setId(ResHelper.getIdRes(context, "tv_dialog_hint"));
	LinearLayout.LayoutParams hintParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	hintParams.topMargin = SizeHelper.fromPxWidth(32);
	hintParams.bottomMargin = SizeHelper.fromPxWidth(32);
	dialogHint.setLayoutParams(hintParams);
	dialogHint.setPadding(SizeHelper.fromPxWidth(18), 0, SizeHelper.fromPxWidth(18), 0);
	dialogHint.setLineSpacing(SizeHelper.fromPxWidth(8), 1);
	int resid = ResHelper.getStringRes(context, "smssdk_make_sure_mobile_detail");
	dialogHint.setText(resid);
	dialogHint.setTextColor(0xffffffff);
	dialogHint.setTextSize(TypedValue.COMPLEX_UNIT_PX, SizeHelper.fromPxWidth(26));
	dialogHint.setGravity(Gravity.CENTER);
	root.addView(dialogHint);

	View line = new View(context);
	LinearLayout.LayoutParams lineParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			SizeHelper.fromPxWidth(1));
	line.setLayoutParams(lineParams);
	line.setBackgroundColor(0xff737373);
	root.addView(line);

	LinearLayout wrapper = new LinearLayout(context);
	LinearLayout.LayoutParams wrapperParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.WRAP_CONTENT);
	wrapper.setLayoutParams(wrapperParams);


	Button ok = new Button(context);
	ok.setId(ResHelper.getIdRes(context, "btn_dialog_ok"));
	LinearLayout.LayoutParams okParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
	okParams.leftMargin = SizeHelper.fromPxWidth(3);
	ok.setLayoutParams(okParams);
	resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
	ok.setBackgroundResource(resid);
	int padding = SizeHelper.fromPxWidth(8);
	ok.setPadding(padding, padding, padding, padding);
	resid = ResHelper.getStringRes(context, "smssdk_ok");
	ok.setText(resid);
	ok.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	ok.setTextColor(0xffffffff);
	wrapper.addView(ok);

	View line2 = new View(context);
	LinearLayout.LayoutParams line2Params = new LinearLayout.LayoutParams(SizeHelper.fromPxWidth(1),
			LinearLayout.LayoutParams.MATCH_PARENT);
	line2.setLayoutParams(line2Params);
	line2.setBackgroundColor(0xff737373);
	wrapper.addView(line2);

	Button cancel = new Button(context);
	cancel.setId(ResHelper.getIdRes(context, "btn_dialog_cancel"));
	LinearLayout.LayoutParams cancelParams = new LinearLayout.LayoutParams(0,SizeHelper.fromPxWidth(78),1);
	cancelParams.rightMargin = SizeHelper.fromPxWidth(3);
	cancel.setLayoutParams(cancelParams);
	resid = ResHelper.getBitmapRes(context, "smssdk_dialog_btn_back");
	cancel.setBackgroundResource(resid);
	cancel.setPadding(padding, padding, padding, padding);
	resid = ResHelper.getStringRes(context, "smssdk_cancel");
	cancel.setText(resid);
	cancel.setTextSize(TypedValue.COMPLEX_UNIT_PX,SizeHelper.fromPxWidth(22));
	cancel.setTextColor(0xffffffff);
	wrapper.addView(cancel);

	root.addView(wrapper);
	return root;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:78,代码来源:BackVerifyDialogLayout.java

示例11: 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

示例12: 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

示例13: addButton

import android.widget.Button; //导入方法依赖的package包/类
private void addButton(final Leaf leaf){
	Button btn = new Button(getActivity());
	btn.setText(leaf.name);
	btn.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	btn.setBackgroundResource(R.drawable.sel_menu2);
	btn.setTextSize(15);
	btn.setPadding(20, 0, 20, 0);
	btn.setTextColor(Color.WHITE);
	btn.setAllCaps(false);


	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, Utils.dip2px(getActivity(), 40));
	lp.gravity = Gravity.CENTER;
	lp.topMargin = Utils.dip2px(getActivity(), 5);
	lp.bottomMargin = Utils.dip2px(getActivity(), 5);
	lp.leftMargin = Utils.dip2px(getActivity(), 5);
	lp.rightMargin = Utils.dip2px(getActivity(), 5);
	ll_root.addView(btn, lp);

	btn.setOnClickListener(new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			if(leaf.attacherClass != null){
				Master.startPage(getActivity(), leaf.attacherClass, null);
			}else if(leaf.activityClass != null){
				Intent intent = new Intent(getActivity(), leaf.activityClass);
				getActivity().startActivity(intent);
			}else{
				Toast.makeText(getActivity(), "sorry,此功能尚未实现", Toast.LENGTH_SHORT).show();
			}
		}
	});

	if(leaf.attacherClass == null && leaf.activityClass == null){

	}else{
		btn.setBackgroundResource(R.drawable.sel_menu3);
	}

}
 
开发者ID:cowthan,项目名称:ayo-menu,代码行数:42,代码来源:MenuItemFragment.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(Context context, int style){
        mContentPadding = ThemeUtil.dpToPx(context, 24);
        mActionMinWidth = ThemeUtil.dpToPx(context, 64);
        mActionHeight = ThemeUtil.dpToPx(context, 36);
        mActionOuterHeight = ThemeUtil.dpToPx(context, 48);
        mActionPadding_h = ThemeUtil.dpToPx(context, 8);
        mActionPadding_w = ThemeUtil.dpToPx(context, 8);
        mActionOuterPadding = ThemeUtil.dpToPx(context, 8);
        mDialogHorizontalPadding = ThemeUtil.dpToPx(context, 40);
        mDialogVerticalPadding = ThemeUtil.dpToPx(context, 24);

        mCardView = new DialogCardView(context);
        mContainer = new ContainerFrameLayout(context);
        mTitle = new TextView(context);
        mPositiveAction = new Button(context);
        mNegativeAction = new Button(context);
        mNeutralAction = new Button(context);

        mCardView.setPreventCornerOverlap(false);
        mCardView.setUseCompatPadding(true);

        mTitle.setId(TITLE);
        mTitle.setGravity(Gravity.START);
//        mTitle.setPadding(mContentPadding, mContentPadding, mContentPadding, mContentPadding - mActionPadding);
        mTitle.setPadding(mContentPadding, mContentPadding, 0, mContentPadding /2);
        mPositiveAction.setId(ACTION_POSITIVE);
        mPositiveAction.setPadding(mActionPadding_w, mActionPadding_h, mActionPadding_w, mActionPadding_h);
        //设置背景
        mPositiveAction.setBackgroundResource(R.drawable.button_white_stroke_green);
        mNegativeAction.setId(ACTION_NEGATIVE);
        mNegativeAction.setPadding(mActionPadding_w, mActionPadding_h, mActionPadding_w, mActionPadding_h);
        mNegativeAction.setBackgroundResource(0);
        mNeutralAction.setId(ACTION_NEUTRAL);
        mNeutralAction.setPadding(mActionPadding_w, mActionPadding_h, mActionPadding_w, mActionPadding_h);
        mNeutralAction.setBackgroundResource(0);

        mContainer.addView(mCardView);
        mCardView.addView(mTitle);
        mCardView.addView(mPositiveAction);
        mCardView.addView(mNegativeAction);
        mCardView.addView(mNeutralAction);

        backgroundColor(ThemeUtil.windowBackground(context, 0xFFFFFFFF));
        elevation(ThemeUtil.dpToPx(context, 4));
        cornerRadius(ThemeUtil.dpToPx(context, 2));
        dimAmount(0.5f);
        layoutDirection(View.LAYOUT_DIRECTION_LOCALE);
        titleTextAppearance(R.style.TextAppearance_AppCompat_Title);
        actionTextAppearance(R.style.TextAppearance_AppCompat_Button);
        dividerColor(0x1E000000);
        dividerHeight(ThemeUtil.dpToPx(context, 1));

        cancelable(true);
        canceledOnTouchOutside(true);
        clearContent();
        onCreate();
        applyStyle(style);

        super.setContentView(mContainer);
    }
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:61,代码来源:Dialog.java


注:本文中的android.widget.Button.setPadding方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。