use of android.graphics.drawable.GradientDrawable in project superCleanMaster by joyoyao.
the class IconRoundCornerProgressBar method setHeaderColor.
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public void setHeaderColor(int color) {
headerColor = color;
int radius = this.radius - (padding / 2);
GradientDrawable gradient = new GradientDrawable();
gradient.setShape(GradientDrawable.RECTANGLE);
gradient.setColor(headerColor);
gradient.setCornerRadii(new float[] { radius, radius, 0, 0, 0, 0, radius, radius });
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
layoutHeader.setBackgroundDrawable(gradient);
} else {
layoutHeader.setBackground(gradient);
}
if (!isProgressBarCreated) {
isHeaderColorSetBeforeDraw = true;
}
}
use of android.graphics.drawable.GradientDrawable in project MaterialDesignLibrary by navasmdc.
the class Card method setBackgroundColor.
// Set color of background
public void setBackgroundColor(int color) {
this.backgroundColor = color;
if (isEnabled())
beforeBackground = backgroundColor;
LayerDrawable layer = (LayerDrawable) getBackground();
GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground);
shape.setColor(backgroundColor);
}
use of android.graphics.drawable.GradientDrawable in project MaterialDesignLibrary by navasmdc.
the class Button method setBackgroundColor.
// Set color of background
public void setBackgroundColor(int color) {
this.backgroundColor = color;
if (isEnabled())
beforeBackground = backgroundColor;
try {
LayerDrawable layer = (LayerDrawable) getBackground();
GradientDrawable shape = (GradientDrawable) layer.findDrawableByLayerId(R.id.shape_bacground);
shape.setColor(backgroundColor);
rippleColor = makePressColor();
} catch (Exception ex) {
// Without bacground
}
}
use of android.graphics.drawable.GradientDrawable in project snackbar by nispok.
the class Snackbar method init.
private MarginLayoutParams init(Context context, Activity targetActivity, ViewGroup parent, boolean usePhoneLayout) {
SnackbarLayout layout = (SnackbarLayout) LayoutInflater.from(context).inflate(R.layout.sb__template, this, true);
layout.setOrientation(LinearLayout.VERTICAL);
Resources res = getResources();
mColor = mColor != mUndefinedColor ? mColor : res.getColor(R.color.sb__background);
mOffset = res.getDimensionPixelOffset(R.dimen.sb__offset);
mUsePhoneLayout = usePhoneLayout;
float scale = res.getDisplayMetrics().density;
View divider = layout.findViewById(R.id.sb__divider);
MarginLayoutParams params;
if (mUsePhoneLayout) {
// Phone
layout.setMinimumHeight(dpToPx(mType.getMinHeight(), scale));
layout.setMaxHeight(dpToPx(mType.getMaxHeight(), scale));
layout.setBackgroundColor(mColor);
params = createMarginLayoutParams(parent, FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, mPhonePosition);
if (mLineColor != null) {
divider.setBackgroundColor(mLineColor);
} else {
divider.setVisibility(View.GONE);
}
} else {
// Tablet/desktop
// Force single-line
mType = SnackbarType.SINGLE_LINE;
layout.setMinimumWidth(res.getDimensionPixelSize(R.dimen.sb__min_width));
layout.setMaxWidth(mMaxWidthPercentage == null ? res.getDimensionPixelSize(R.dimen.sb__max_width) : DisplayCompat.getWidthFromPercentage(targetActivity, mMaxWidthPercentage));
layout.setBackgroundResource(R.drawable.sb__bg);
GradientDrawable bg = (GradientDrawable) layout.getBackground();
bg.setColor(mColor);
params = createMarginLayoutParams(parent, FrameLayout.LayoutParams.WRAP_CONTENT, dpToPx(mType.getMaxHeight(), scale), mWidePosition);
if (mLineColor != null) {
divider.setBackgroundResource(R.drawable.sb__divider_bg);
GradientDrawable dbg = (GradientDrawable) divider.getBackground();
dbg.setColor(mLineColor);
} else {
divider.setVisibility(View.GONE);
}
}
if (mDrawable != mUndefinedDrawable)
setBackgroundDrawable(layout, res.getDrawable(mDrawable));
snackbarText = (TextView) layout.findViewById(R.id.sb__text);
snackbarText.setText(mText);
snackbarText.setTypeface(mTextTypeface);
if (mTextColor != mUndefinedColor) {
snackbarText.setTextColor(mTextColor);
}
snackbarText.setMaxLines(mType.getMaxLines());
snackbarAction = (TextView) layout.findViewById(R.id.sb__action);
if (!TextUtils.isEmpty(mActionLabel)) {
requestLayout();
snackbarAction.setText(mActionLabel);
snackbarAction.setTypeface(mActionTypeface);
if (mActionColor != mUndefinedColor) {
snackbarAction.setTextColor(mActionColor);
}
snackbarAction.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (mActionClickListener != null) {
// 2) If we aren't allowing multiple clicks, that this is the first click
if (!mIsDismissing && (!mActionClicked || mShouldAllowMultipleActionClicks)) {
mActionClickListener.onActionClicked(Snackbar.this);
mActionClicked = true;
}
}
if (mShouldDismissOnActionClicked) {
dismiss();
}
}
});
snackbarAction.setMaxLines(mType.getMaxLines());
} else {
snackbarAction.setVisibility(GONE);
}
View inner = layout.findViewById(R.id.sb__inner);
inner.setClickable(true);
if (mCanSwipeToDismiss && res.getBoolean(R.bool.sb__is_swipeable)) {
inner.setOnTouchListener(new SwipeDismissTouchListener(this, null, new SwipeDismissTouchListener.DismissCallbacks() {
@Override
public boolean canDismiss(Object token) {
return true;
}
@Override
public void onDismiss(View view, Object token) {
if (view != null) {
if (mActionSwipeListener != null) {
mActionSwipeListener.onSwipeToDismiss();
}
dismiss(false);
}
}
@Override
public void pauseTimer(boolean shouldPause) {
if (isIndefiniteDuration()) {
return;
}
if (shouldPause) {
removeCallbacks(mDismissRunnable);
mSnackbarFinish = System.currentTimeMillis();
} else {
mTimeRemaining -= (mSnackbarFinish - mSnackbarStart);
startTimer(mTimeRemaining);
}
}
}));
}
return params;
}
use of android.graphics.drawable.GradientDrawable in project JamsMusicPlayer by psaravan.
the class QuickScroll method setPopupColor.
/**
* Sets the popup colors, when QuickScroll.TYPE_POPUP is selected as type.
* <p/>
*
* @param backgroundcolor the background color of the TextView
* @param bordercolor the background color of the border surrounding the TextView
* @param textcolor the color of the text
*/
public void setPopupColor(final int backgroundcolor, final int bordercolor, final int borderwidthDPI, final int textcolor, float cornerradiusDPI) {
final GradientDrawable popupbackground = new GradientDrawable();
popupbackground.setCornerRadius(cornerradiusDPI * getResources().getDisplayMetrics().density);
popupbackground.setStroke((int) (borderwidthDPI * getResources().getDisplayMetrics().density), bordercolor);
popupbackground.setColor(backgroundcolor);
if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN)
scrollIndicatorTextView.setBackgroundDrawable(popupbackground);
else
scrollIndicatorTextView.setBackground(popupbackground);
scrollIndicatorTextView.setTextColor(textcolor);
}
Aggregations