当前位置: 首页>>代码示例>>Java>>正文


Java ImageButton.setBackgroundDrawable方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:19,代码来源:SafetyKeyboard.java

示例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;
}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:19,代码来源:ImageViewButtonItem.java

示例3: setDoneKey

import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDoneKey(ImageButton buttonView) {
    if (null != mDoneForeSelector) {
        buttonView.setImageDrawable(mDoneForeSelector);

    }
    if (null != mDoneBgSelector) {
        buttonView.setBackgroundDrawable(mDoneBgSelector);
    }
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:10,代码来源:SafetyKeyboard.java

示例4: setDelKey

import android.widget.ImageButton; //导入方法依赖的package包/类
private void setDelKey(ImageButton buttonView) {
    if (null != mDelForeSelector) {
        buttonView.setImageDrawable(mDelForeSelector);
    }
    if (null != mDelBgSelector) {
        buttonView.setBackgroundDrawable(mDelBgSelector);
    }
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:9,代码来源:SafetyKeyboard.java

示例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);
}
 
开发者ID:1313ou,项目名称:TreebolicLib,代码行数:36,代码来源:Toolbar.java


注:本文中的android.widget.ImageButton.setBackgroundDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。