本文整理了Java中android.widget.Button.setBackground()
方法的一些代码示例,展示了Button.setBackground()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setBackground()
方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:setBackground
暂无
代码示例来源:origin: JavaNoober/BackgroundLibrary
.setGradientAngle(0).setGradientColor(Color.parseColor("#63B8FF"), Color.parseColor("#4F94CD")).build();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
btnTest2.setBackground(drawable2);
}else {
btnTest2.setBackgroundDrawable(drawable2);
.build();
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN){
btnTest3.setBackground(drawable3);
}else {
btnTest3.setBackgroundDrawable(drawable3);
代码示例来源:origin: JmStefanAndroid/PVCloudGroupn
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setButtonSubBackgroud(Drawable backgroud){
this.mBtnSub.setBackground(backgroud);
}
代码示例来源:origin: yaozs/YzsLib
public void setRemoveButtonBackground(Drawable removeButtonBackground) {
this.removeButtonBackground = removeButtonBackground;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mButtonRemove.setBackground(removeButtonBackground);
} else {
mButtonRemove.setBackgroundDrawable(removeButtonBackground);
}
}
代码示例来源:origin: gaolhjy/enjoyshop
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setButtonAddBackgroud(Drawable backgroud) {
this.mBtnAdd.setBackground(backgroud);
}
代码示例来源:origin: gitsindonesia/baso
public void setFinishedButtonBackground(Drawable finishedButtonBackground) {
mFinishedButtonBackground = finishedButtonBackground;
if (finishedButtonBackground != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mStoppedButton.setBackground(mFinishedButtonBackground);
} else {
mStoppedButton.setBackgroundDrawable(mFinishedButtonBackground);
}
}
}
代码示例来源:origin: gaolhjy/enjoyshop
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setButtonSubBackgroud(Drawable backgroud) {
this.mBtnSub.setBackground(backgroud);
}
代码示例来源:origin: yaozs/YzsLib
public void setAddButtonBackground(Drawable addButtonBackground) {
this.addButtonBackground = addButtonBackground;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mButtonAdd.setBackground(addButtonBackground);
} else {
mButtonAdd.setBackgroundDrawable(addButtonBackground);
}
}
代码示例来源:origin: JmStefanAndroid/PVCloudGroupn
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setRightButtonIcon(Drawable icon){
if(mRightButton !=null){
mRightButton.setBackground(icon);
mRightButton.setVisibility(VISIBLE);
}
}
代码示例来源:origin: searchy2/CustomPermissionsDialogue
public void run() {
mButton.setText("Grant Permissions");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
mButton.setBackground(ContextCompat.getDrawable(mContext, R.drawable.icon_add));
}
else
{
mButton.setBackgroundDrawable(ContextCompat.getDrawable(mContext, R.drawable.icon_add));
}
}
};
代码示例来源:origin: gaolhjy/enjoyshop
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public void setRightButtonIcon(Drawable icon) {
if (mRightButton != null) {
mRightButton.setBackground(icon);
mRightButton.setVisibility(VISIBLE);
}
}
代码示例来源:origin: Catrobat/Paintroid
private void setButtonColor(int color) {
buttonNewColor.setBackground(CustomColorDrawable.createDrawable(color));
int referenceColor = (Color.red(color) + Color.blue(color) + Color.green(color)) / 3;
if (referenceColor <= 128 && Color.alpha(color) > 5) {
buttonNewColor.setTextColor(Color.WHITE);
} else {
buttonNewColor.setTextColor(Color.BLACK);
}
}
代码示例来源:origin: watson-developer-cloud/speech-android-sdk
@Override
public void run() {
int iDrawable = bRecording ? R.drawable.button_record_stop : R.drawable.button_record_start;
Button btnRecord = (Button)mView.findViewById(R.id.buttonRecord);
btnRecord.setBackground(getResources().getDrawable(iDrawable));
}
};
代码示例来源:origin: AmazMod/AmazMod
@OnClick(R.id.activity_notification_button_reply)
public void clickReply(Button b) {
b.setBackground(getDrawable(R.drawable.reply_dark_grey));
text.setVisibility(View.GONE);
time.setVisibility(View.GONE);
buttonsLayout.setVisibility(View.GONE);
addReplies();
}
代码示例来源:origin: AmazMod/AmazMod
@OnClick(R.id.activity_notification_button_close)
public void clickClose(Button b) {
b.setBackground(getDrawable(R.drawable.reply_dark_grey));
//mustLockDevice = true;
finish();
}
代码示例来源:origin: mooshim/Mooshimeter-AndroidApp
private void disableableButtonRefresh(Button b, String title, boolean en) {
final Drawable bg = en? getNormalBG(): getAutoBG();
b.setText(title);
b.setBackground(bg);
}
private void autoButtonRefresh(final Button b, final String title, boolean auto) {
代码示例来源:origin: mooshim/Mooshimeter-AndroidApp
@Override
public void run() {
bv.setEnabled(true);
bv.setAlpha((float) 1.0);
int bgid = finalM.isConnected() ? R.drawable.connected : R.drawable.disconnected;
bv.setBackground(getResources().getDrawable(bgid));
}
});
代码示例来源:origin: mooshim/Mooshimeter-AndroidApp
@Override
public void run() {
float button_height = b.getHeight(); // Button height in raw pixels
b.setTextSize(TypedValue.COMPLEX_UNIT_PX,button_height/3); // Divisor arrived at empirically
b.setBackground(bg);
}
});
代码示例来源:origin: AmazMod/AmazMod
private void setButtonTheme(Button button, String string) {
button.setIncludeFontPadding(false);
button.setMinHeight(24);
button.setMinWidth(120);
button.setText(string);
button.setAllCaps(true);
button.setTextColor(Color.parseColor("#000000"));
button.setBackground(mContext.getDrawable(R.drawable.reply_grey));
}
代码示例来源:origin: AmazMod/AmazMod
private void setButtonTheme(Button button, String string) {
button.setIncludeFontPadding(false);
button.setMinHeight(24);
button.setMinWidth(120);
button.setText(string);
button.setAllCaps(true);
button.setTextColor(Color.parseColor("#000000"));
button.setBackground(mContext.getDrawable(R.drawable.reply_grey));
}
代码示例来源:origin: AmazMod/AmazMod
private void setButtonTheme(Button button) {
button.setIncludeFontPadding(false);
button.setMinHeight(24);
button.setMinWidth(120);
button.setText(getResources().getString(R.string.close));
button.setAllCaps(false);
button.setTextColor(Color.parseColor("#000000"));
button.setBackground(mContext.getDrawable(R.drawable.reply_grey));
}
内容来源于网络,如有侵权,请联系作者删除!