android.widget.Button.setBackgroundDrawable()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中android.widget.Button.setBackgroundDrawable()方法的一些代码示例,展示了Button.setBackgroundDrawable()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button.setBackgroundDrawable()方法的具体详情如下:
包路径:android.widget.Button
类名称:Button
方法名:setBackgroundDrawable

Button.setBackgroundDrawable介绍

暂无

代码示例

代码示例来源:origin: aa112901/remusic

@Override
public void setBackgroundDrawable(Drawable background) {
  super.setBackgroundDrawable(background);
  if (mBackgroundHelper != null) {
    mBackgroundHelper.setBackgroundDrawableExternal(background);
  }
}

代码示例来源:origin: andkulikov/Transitions-Everywhere

@Override
public void onClick(View v) {
  TransitionManager.beginDelayedTransition(transitionsContainer, new Recolor());
  mColorsInverted = !mColorsInverted;
  button.setTextColor(getResources().getColor(!mColorsInverted ? R.color.second_accent : R.color.accent));
  button.setBackgroundDrawable(
    new ColorDrawable(getResources().getColor(!mColorsInverted ? R.color.accent : R.color.second_accent)));
}

代码示例来源:origin: facebook/facebook-android-sdk

doneButton.setBackgroundDrawable(doneButtonBackground);

代码示例来源:origin: WVector/AppUpdate

/**
 * 设置
 *
 * @param color    主色
 * @param topResId 图片
 */
private void setDialogTheme(int color, int topResId) {
  mTopIv.setImageResource(topResId);
  mUpdateOkButton.setBackgroundDrawable(DrawableUtil.getDrawable(AppUpdateUtils.dip2px(4, getActivity()), color));
  mNumberProgressBar.setProgressTextColor(color);
  mNumberProgressBar.setReachedBarColor(color);
  //随背景颜色变化
  mUpdateOkButton.setTextColor(ColorUtil.isTextColorDark(color) ? Color.BLACK : Color.WHITE);
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void setBackgroundDrawable(Drawable background) {
  if (background instanceof RippleDrawable) {
    setRippleDrawable((RippleDrawable) background);
    return;
  }
  if (rippleDrawable != null && rippleDrawable.getStyle() == RippleDrawable.Style.Background) {
    rippleDrawable.setCallback(null);
    rippleDrawable = null;
  }
  super.setBackgroundDrawable(background);
  updateBackgroundTint();
}

代码示例来源:origin: ZieIony/Carbon

@Override
public void setRippleDrawable(RippleDrawable newRipple) {
  if (rippleDrawable != null) {
    rippleDrawable.setCallback(null);
    if (rippleDrawable.getStyle() == RippleDrawable.Style.Background)
      super.setBackgroundDrawable(rippleDrawable.getBackground());
  }
  if (newRipple != null) {
    newRipple.setCallback(this);
    newRipple.setBounds(0, 0, getWidth(), getHeight());
    newRipple.setState(getDrawableState());
    ((Drawable) newRipple).setVisible(getVisibility() == VISIBLE, false);
    if (newRipple.getStyle() == RippleDrawable.Style.Background)
      super.setBackgroundDrawable((Drawable) newRipple);
  }
  rippleDrawable = newRipple;
}

代码示例来源:origin: JavaNoober/BackgroundLibrary

btnTest2.setBackground(drawable2);
}else {
  btnTest2.setBackgroundDrawable(drawable2);
  btnTest3.setBackground(drawable3);
}else {
  btnTest3.setBackgroundDrawable(drawable3);

代码示例来源: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: 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: Car-eye-team/Car-eye-device

@Override
  public void onClick(View v) {
    playIndex = (playIndex+1)%mFileList.size();
    Log.d(TAG,"next file = "+mFileList.get(playIndex));
    //playUrl(mFileList.get(playIndex));
    url= (Uri.parse("file://"+mFileList.get(playIndex))).toString();
    playUrl(url);    
    
    playButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.play));
  }
});

代码示例来源: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: sealtalk/sealtalk-android

@Override
public void onTick(long millisUntilFinished) {
  mGetCode.setText("seconds:" + String.valueOf(millisUntilFinished / 1000));
  mGetCode.setClickable(false);
  mGetCode.setBackgroundDrawable(getResources().getDrawable(R.drawable.rs_select_btn_gray));
}

代码示例来源:origin: sealtalk/sealtalk-android

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  if (s.length() > 5) {
    mConfirm.setClickable(true);
    mConfirm.setBackgroundDrawable(getResources().getDrawable(R.drawable.rs_select_btn_blue));
  } else {
    mConfirm.setClickable(false);
    mConfirm.setBackgroundDrawable(getResources().getDrawable(R.drawable.rs_select_btn_gray));
  }
}

代码示例来源:origin: com.albedinsky.android/ui-widget-common

/**
 */
@Override
@SuppressWarnings("deprecation")
public void setBackgroundDrawable(Drawable background) {
  super.setBackgroundDrawable(background);
  this.ensureDecorator();
  mDecorator.applyBackgroundTint();
}

代码示例来源:origin: com.albedinsky.android/ui

/**
 */
@Override
@SuppressWarnings("deprecation")
public void setBackgroundDrawable(Drawable background) {
  super.setBackgroundDrawable(background);
  this.ensureDecorator();
  mDecorator.applyBackgroundTint();
}

代码示例来源: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: gizwits/GOpenSource_AppKit_Android_AS

private void initView() {
  btnAgain = (Button) findViewById(R.id.btnAgain);
  // 配置文件部署
  btnAgain.setBackgroundDrawable(GosDeploy.setButtonBackgroundColor());
  btnAgain.setTextColor(GosDeploy.setButtonTextColor());
}

代码示例来源:origin: Tencent/RapidView

public void run(RapidParserObject object, Object view, Var value){
  Map<String,String> map = RapidStringUtils.stringToMap(value.getString());
  GradientDrawable drawable = new GradientDrawable();
  String width = map.get("strokewidth");
  String color = map.get("strokecolor");
  initGradientDrawableCornerRadius(object.getContext(), drawable, map.get("cornerradius"));
  initGradientDrawableColor(drawable, map.get("color"));
  initGradientDrawableShape(drawable, map.get("shape"));
  if( width != null && color != null ){
    initGradientStroke(drawable, width, color);
  }
  ((Button) view).setBackgroundDrawable(drawable);
}

代码示例来源:origin: gizwits/GOpenSource_AppKit_Android_AS

@Override
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked) {
      btnNext.setBackgroundDrawable(GosDeploy.setButtonBackgroundColor());;
      btnNext.setClickable(true);
    } else {
      btnNext.setBackgroundResource(R.drawable.btn_next_shape_gray);
      btnNext.setClickable(false);
    }
  }
});

代码示例来源:origin: gizwits/GOpenSource_AppKit_Android_AS

@Override
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked) {
      btnNext.setBackgroundDrawable(GosDeploy.setButtonBackgroundColor());
      btnNext.setClickable(true);
    } else {
      btnNext.setBackgroundResource(R.drawable.btn_next_shape_gray);
      btnNext.setClickable(false);
    }
  }
});

相关文章

Button类方法