當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。