本文整理汇总了Java中android.widget.Button.setTextSize方法的典型用法代码示例。如果您正苦于以下问题:Java Button.setTextSize方法的具体用法?Java Button.setTextSize怎么用?Java Button.setTextSize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.Button
的用法示例。
在下文中一共展示了Button.setTextSize方法的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;
}
示例2: setMdBtnStytle
import android.widget.Button; //导入方法依赖的package包/类
/**
* 设置MD风格样式
*/
public static void setMdBtnStytle(BuildBean bean) {
Button btnPositive =
bean.alertDialog.getButton(AlertDialog.BUTTON_POSITIVE);
Button btnNegative =
bean.alertDialog.getButton(AlertDialog.BUTTON_NEGATIVE);
Button btnNatural =
bean.alertDialog.getButton(AlertDialog.BUTTON_NEUTRAL);
if (btnPositive != null && btnNegative != null) {
btnPositive.setTextSize(bean.btnTxtSize);
btnNegative.setTextSize(bean.btnTxtSize);
btnNatural.setTextSize(bean.btnTxtSize);
if (bean.btn1Color != 0)
btnPositive.setTextColor(getColor(null, bean.btn1Color));
if (bean.btn2Color != 0)
btnNegative.setTextColor(getColor(null, bean.btn2Color));
if (bean.btn3Color != 0)
btnNatural.setTextColor(getColor(null, bean.btn3Color));
}
Window window = bean.alertDialog.getWindow();
window.setGravity(bean.gravity);
}
示例3: 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);
}
示例4: 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);
}
}
示例5: 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;
}
示例6: 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;
}
示例7: genUrls
import android.widget.Button; //导入方法依赖的package包/类
private void genUrls(){
urlList = new ArrayList<>();
diffRes = new HashMap<>();
layoutSources.removeAllViews();
buttons = new ArrayList<>();
if(live.getUrllist() != null){
urlIndex = 0;
urlList = new ArrayList<>(Arrays.asList(live.getUrllist().split("#")));
for(String i:urlList){
String name = getName(i);
diffRes.put(name,i);
Button btn = new Button(getApplicationContext());
btn.setText(name);
btn.setWidth(MATCH_PARENT);
btn.setHeight(dp2px(48));
btn.setTextSize(18);
btn.setTextColor(Color.parseColor("#FFFFFF"));
btn.setBackgroundColor(Color.parseColor("#00ffffff"));
buttons.add(btn);
layoutSources.addView(btn);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
urlIndex = buttons.indexOf(v);
playTv(diffRes.get(((Button)v).getText()));
videoController.setIsLiveOrNot(true);
hideSettingLayout();
}
});
}
}else{
urlIndex = -1;
}
}
示例8: initialize
import android.widget.Button; //导入方法依赖的package包/类
public void initialize(Context context) {
this.setBackgroundColor(Color.WHITE);
final int width = 90;
final int height = 90;
final int margin = 13;
final int length = PointPath.mPathColors.length;
int left = 10;
for (int i = 0; i < length; ++i) {
int color = PointPath.mPathColors[i];
ImageView imgBtn = new ImageView(context);
if (CURRENT_TYPE == STROCK_TYPE) {
Bitmap bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_4444);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColor(Color.RED);
paint.setStrokeWidth(PointPath.mPenStrock[i]);
canvas.drawLine(0, height, width, 0, paint);
imgBtn.setImageBitmap(bitmap);
imgBtn.setBackgroundColor(Color.WHITE);
} else {
imgBtn.setBackgroundColor(color);
}
imgBtn.setOnClickListener(m_clickListener);
imgBtn.setTag(i);
LayoutParams params = new LayoutParams(width, height);
params.setMargins(left, 30, 0, 0);
params.addRule(Gravity.CENTER_VERTICAL);
left += (margin + width);
this.addView(imgBtn, params);
}
// Cancel button.
Button btnCancel = new Button(context);
btnCancel.setText("cancel");
btnCancel.setId(CANCEL_BUTTON_ID);
btnCancel.setTextSize(8);
btnCancel.setOnClickListener(m_clickListener);
LayoutParams btnCancelparams = new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, height);
btnCancelparams.addRule(Gravity.CENTER);
left += 10;
btnCancelparams.setMargins(left, 30, 0, 0);
this.addView(btnCancel, btnCancelparams);
}
示例9: 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);
}
示例10: 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);
}
}
});
}
示例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;
}
示例12: 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;
}
示例13: beautyButtonGreen
import android.widget.Button; //导入方法依赖的package包/类
protected void beautyButtonGreen(Button mButton, String str, OnClickListener mOnClickListener) {
mButton.setText(str);
mButton.setTextSize(16.0f);
mButton.setOnClickListener(mOnClickListener);
SDKUtils.setBackground(mButton, this.crMgmt.getStatusDrawable("common_btn_blue_pressed", "common_btn_blue_normal", true));
mButton.setTextColor(this.crMgmt.createSelector("#ffffff", "#ffffff"));
}
示例14: 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);
}
}
示例15: 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;
}