本文整理了Java中android.widget.Button.measure()
方法的一些代码示例,展示了Button.measure()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.measure()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:measure
暂无
代码示例来源:origin: behindeye/WxPhoneNumberHelper
public static Bitmap getBitmap(Context context, String paramString,
int bgsid, int textsize, int textcolor) {
Button localButton = new Button(context);
localButton.setBackgroundResource(bgsid);
localButton.setTextSize(TypedValue.COMPLEX_UNIT_SP, textsize);
localButton.setText(paramString);
localButton.setTextColor(textcolor);
localButton.setDrawingCacheEnabled(true);
localButton.measure(View.MeasureSpec.makeMeasureSpec(0, 0),
View.MeasureSpec.makeMeasureSpec(0, 0));
localButton.layout(0, 0, localButton.getMeasuredWidth(),
localButton.getMeasuredHeight());
localButton.buildDrawingCache();
return Bitmap.createBitmap(localButton.getDrawingCache());
}
代码示例来源:origin: ahmclishihao/gankS
/**
* 弹出一个popupwindow
*/
public static void getPopupWindow(View anchor, Context context, String text, final View.OnClickListener cl) {
Button button = new Button(context);
button.setBackgroundResource(R.drawable.selector_btn_save);
button.setText(text);
button.setTextColor(Color.BLACK);
button.setPadding(10, 5, 10, 5);
button.setOnClickListener(cl);
button.measure(0, 0);
final PopupWindow popupWindow = new PopupWindow(button, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, true);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
// 设置背景和focusable使得可以点击消失
popupWindow.setFocusable(true);
if (Build.VERSION.SDK_INT >= 21)
popupWindow.setElevation(5);
popupWindow.showAsDropDown(anchor, anchor.getMeasuredWidth() / 2 - button.getMeasuredWidth() / 2, -anchor.getMeasuredHeight() / 2 - button.getMeasuredHeight() / 2);
// 回调 提供的监听
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// 两个View.OnClickListener不冲突
cl.onClick(v);
popupWindow.dismiss();
}
});
}
代码示例来源:origin: stackoverflow.com
mButton.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
mButtonWidth = mButton.getMeasuredWidth();
内容来源于网络,如有侵权,请联系作者删除!