本文整理了Java中android.widget.ImageButton.setPadding()
方法的一些代码示例,展示了ImageButton.setPadding()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageButton.setPadding()
方法的具体详情如下:
包路径:android.widget.ImageButton
类名称:ImageButton
方法名:setPadding
暂无
代码示例来源:origin: WomenWhoCode/WomenWhoCode
private void setColorFilter() {
if (!TextUtils.isEmpty(etMessage.getText())) {
btnSend.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.teal));
btnSend.setPadding(10, 4, 10, 4);
} else {
btnSend.setBackgroundColor(ContextCompat.getColor(getContext(), R.color.lightestGray));
btnSend.setPadding(10, 4, 10, 4);
}
}
代码示例来源:origin: derry/delion
@Override
public void setCustomActionButton(Drawable drawable, String description,
OnClickListener listener) {
Resources resources = getResources();
// The height will be scaled to match spec while keeping the aspect ratio, so get the scaled
// width through that.
int sourceHeight = drawable.getIntrinsicHeight();
int sourceScaledHeight = resources.getDimensionPixelSize(R.dimen.toolbar_icon_height);
int sourceWidth = drawable.getIntrinsicWidth();
int sourceScaledWidth = sourceWidth * sourceScaledHeight / sourceHeight;
int minPadding = resources.getDimensionPixelSize(R.dimen.min_toolbar_icon_side_padding);
int sidePadding = Math.max((2 * sourceScaledHeight - sourceScaledWidth) / 2, minPadding);
int topPadding = mCustomActionButton.getPaddingTop();
int bottomPadding = mCustomActionButton.getPaddingBottom();
mCustomActionButton.setPadding(sidePadding, topPadding, sidePadding, bottomPadding);
mCustomActionButton.setImageDrawable(drawable);
mCustomActionButton.setContentDescription(description);
mCustomActionButton.setOnClickListener(listener);
mCustomActionButton.setVisibility(VISIBLE);
updateButtonsTint();
}
代码示例来源:origin: stackoverflow.com
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) { // if it's not recycled, initialize some
// attributes
LayoutInflater li = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = li.inflate(R.layout.icon_launcher, null);
}
TextView tv = (TextView) convertView.findViewById(R.id.icon_text);
ImageButton ib = (ImageButton) convertView.findViewById(R.id.icon_image);
LinearLayout icon = (LinearLayout) convertView
.findViewById(R.id.icon_launcher);
// icon.setLayoutParams(new GridView.LayoutParams(203,200));
ib.setScaleType(ib.getScaleType().FIT_XY);
ib.setPadding(1, 1, 1, 1);
ib.setFocusable(false);
ib.setClickable(false);
ib.setImageBitmap(BitmapFactory.decodeFile(mThumbIds.get(position)));
tv.setText(mTextsIds.get(position));
return convertView;
}
代码示例来源:origin: laizimo/richeditor
@NonNull
@Override
public ImageButton createView() {
ImageButton imageView = new ImageButton(getContext());
if(!enableAutoSet) {
TypedArray typedArray = getContext().obtainStyledAttributes(new int[]{R.attr.selectableItemBackgroundBorderless});
Drawable drawable = typedArray.getDrawable(0);
imageView.setBackgroundDrawable(drawable);
typedArray.recycle();
}else
imageView.setBackgroundDrawable(null);
imageView.setImageResource(idRes);
imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
imageView.setPadding(12, 32, 12, 32);
return imageView;
}
代码示例来源:origin: stackoverflow.com
imageButton.setPadding(0, 10, 0, 10);
imageButton.setScaleType(ScaleType.FIT_CENTER);
imageButton.setBackgroundResource(R.drawable.bg_button);
代码示例来源:origin: WomenWhoCode/WomenWhoCode
btnSend.setPadding(10, 4, 10, 4);
etMessage = (EditText) view.findViewById(R.id.etMessage);
代码示例来源:origin: wuhenzhizao/android-titlebar
btnRight.setBackgroundColor(Color.TRANSPARENT);
btnRight.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
btnRight.setPadding(PADDING_12, 0, PADDING_12, 0);
btnRight.setOnClickListener(this);
rlMain.addView(btnRight, rightInnerParams);
代码示例来源:origin: wuhenzhizao/android-titlebar
btnLeft.setBackgroundColor(Color.TRANSPARENT);
btnLeft.setImageResource(leftImageResource);
btnLeft.setPadding(PADDING_12, 0, PADDING_12, 0);
btnLeft.setOnClickListener(this);
代码示例来源:origin: marzika/Snapprefs
upload = new ImageButton(HookMethods.SnapContext);
upload.setLayoutParams(layoutParams);
upload.setPadding(padding, padding, padding, padding);
upload.setBackgroundColor(0);
代码示例来源:origin: stackoverflow.com
imageButton.setLayoutParams(new GridView.LayoutParams(100, 100));
imageButton.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageButton.setPadding(0, 0, 0, 0);
imageButton.setFocusable(false);
} else {
代码示例来源:origin: stackoverflow.com
imageButton.setLayoutParams(new GridView.LayoutParams(100, 100));
imageButton.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageButton.setPadding(0, 0, 0, 0);
imageButton.setFocusable(false);
} else {
代码示例来源:origin: stackoverflow.com
public View getView(int position, View convertView, ViewGroup parent) {
final ImageButton button;
if (convertView == null) {
button = new ImageButton(mContext);
button.setPadding(2,2,2,2);
} else {
button = (ImageButton) convertView;
}
button.setId(position);
button.setImageResource(mThumbIds[position]);
button.setScaleType(ImageButton.ScaleType.CENTER_INSIDE);
//Scale button using layout params
double parentWidth = ((MainActivity) mContext).findViewById(R.id.gridview).getWidth();
double width = button.getDrawable().getIntrinsicWidth();
double height = button.getDrawable().getIntrinsicHeight();
double scalex = parentWidth / parentWidth;
double scaley = parentWidth / width;
int newWidth = (int) (width * scalex);
int newHeight = (int) (height * scaley);
button.setLayoutParams(new GridView.LayoutParams(newWidth, newHeight));
return button;
}
代码示例来源:origin: derry/delion
a.recycle();
mCloseButton.setBackground(closeButtonBackground);
mCloseButton.setPadding(mPadding, mPadding, mPadding, mPadding);
mCloseButton.setOnClickListener(this);
mCloseButton.setContentDescription(res.getString(R.string.infobar_close));
代码示例来源:origin: JustinRoom/JSCKit
params2.gravity = Gravity.CENTER_VERTICAL|Gravity.RIGHT;
ImageButton imageButton = new ImageButton(inflater.getContext(), null, android.R.style.Widget_Material_Light_Button_Borderless);
imageButton.setPadding(padding, padding, padding, padding);
imageButton.setImageResource(R.drawable.ic_action_info);
frameLayout.addView(imageButton, params2);
代码示例来源:origin: wasdennnoch/AndroidN-ify
@Override
public void handleLayoutInflated(LayoutInflatedParam liparam) throws Throwable {
ImageButton action = (ImageButton) liparam.view;
Context context = action.getContext();
ResourceUtils res = ResourceUtils.getInstance(context);
int width_height = res.getDimensionPixelSize(R.dimen.notification_media_action_width);
int padding = ResourceUtils.getInstance(context).getDimensionPixelSize(R.dimen.notification_media_action_padding);
LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(width_height, width_height);
lParams.setMarginEnd(res.getDimensionPixelSize(R.dimen.notification_media_action_margin));
lParams.setMargins(0, 0, res.getDimensionPixelSize(R.dimen.notification_media_action_margin), 0);
action.setLayoutParams(lParams);
action.setPadding(padding, padding, padding, padding);
action.setBackground(res.getDrawable(R.drawable.notification_material_media_action_background));
}
});
代码示例来源:origin: AlexMofer/ProjectX
custom.recycle();
mButton.setPadding(paddingVertical, paddingHorizontal, paddingVertical, paddingHorizontal);
mButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
代码示例来源:origin: marzika/Snapprefs
saveSnapButton.setLayoutParams(layoutParams);
saveSnapButton.setScaleType(ImageView.ScaleType.FIT_XY);
saveSnapButton.setPadding(0,0,0,0);
saveSnapButton.setAdjustViewBounds(true);
saveSnapButton.setBackgroundColor(0);
代码示例来源:origin: marzika/Snapprefs
super.setLayoutParams(newParams);
this.setAdjustViewBounds(true);
super.setPadding(0, 0, 0, 0);
代码示例来源:origin: stackoverflow.com
btn.setPadding(0, 0, 0, 0);
btn.setLayoutParams(params);
btn.setScaleType(ImageView.ScaleType.CENTER_CROP);
代码示例来源:origin: derry/delion
button.setBackground(null);
button.setImageDrawable(tintedDrawable);
button.setPadding(0, 0, 0, 0);
view = button;
内容来源于网络,如有侵权,请联系作者删除!