本文整理匯總了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);
}