本文整理汇总了Java中android.widget.ImageButton.setBackgroundDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java ImageButton.setBackgroundDrawable方法的具体用法?Java ImageButton.setBackgroundDrawable怎么用?Java ImageButton.setBackgroundDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.ImageButton
的用法示例。
在下文中一共展示了ImageButton.setBackgroundDrawable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setNumberKey
import android.widget.ImageButton; //导入方法依赖的package包/类
private void setNumberKey(ImageButton buttonView, int key) {
Drawable tempDrawable = null;
if (null != mNumForeSelectorArray[key]) {
tempDrawable = mNumForeSelectorArray[key].getConstantState()
.newDrawable();
buttonView.setImageDrawable(tempDrawable);
}
if (null != mNumBgSelectorArray
&& null != mNumBgSelectorArray[key]) {
tempDrawable = mNumBgSelectorArray[key].getConstantState()
.newDrawable();
buttonView.setBackgroundDrawable(tempDrawable);
} else if (null != mNumBgDrawSelector) {
tempDrawable = mNumBgDrawSelector.getConstantState()
.newDrawable();
buttonView.setBackgroundDrawable(tempDrawable);
}
}
示例2: createView
import android.widget.ImageButton; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@NonNull
@Override
public ImageButton createView() {
ImageButton imageViewButton = new ImageButton(getContext());
if(!enableAutoSet) {
//无边框的带有水波纹的按钮样式
TypedArray typedArray = getContext().obtainStyledAttributes(new int[]{R.attr.selectableItemBackgroundBorderless});
Drawable drawable = typedArray.getDrawable(0);
imageViewButton.setBackgroundDrawable(drawable);
typedArray.recycle();
}else
imageViewButton.setBackgroundDrawable(null);
imageViewButton.setImageResource(idRes);
imageViewButton.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
return imageViewButton;
}
示例3: setDoneKey
import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDoneKey(ImageButton buttonView) {
if (null != mDoneForeSelector) {
buttonView.setImageDrawable(mDoneForeSelector);
}
if (null != mDoneBgSelector) {
buttonView.setBackgroundDrawable(mDoneBgSelector);
}
}
示例4: setDelKey
import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDelKey(ImageButton buttonView) {
if (null != mDelForeSelector) {
buttonView.setImageDrawable(mDelForeSelector);
}
if (null != mDelBgSelector) {
buttonView.setBackgroundDrawable(mDelBgSelector);
}
}
示例5: addButton
import android.widget.ImageButton; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
@Override
public void addButton(@NonNull final Button button, @NonNull final ActionListener thisListener)
{
// interface button to implementation
final String name = button.name();
final ButtonImplementation impl = ButtonImplementation.valueOf(name);
// new button
final ImageButton imageButton = new ImageButton(getContext());
imageButton.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT, android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
// drawable
final int thisIconIndex = impl.getIconIndex();
final Drawable bitmapDrawable = this.drawables[thisIconIndex];
// tint drawable
Utils.tint(bitmapDrawable, this.iconTint);
// button drawable
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
{
imageButton.setBackground(bitmapDrawable);
}
else
{
imageButton.setBackgroundDrawable(bitmapDrawable);
}
// listener
imageButton.setOnClickListener(thisListener::onAction);
// add
this.panel.addView(imageButton, this.layoutParams);
}