android.graphics.drawable.GradientDrawable Java Examples
The following examples show how to use
android.graphics.drawable.GradientDrawable.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: OverlappedWidget.java From fangzhuishushenqi with Apache License 2.0 | 6 votes |
@Override protected void drawCurrentPageShadow(Canvas canvas) { canvas.save(); GradientDrawable shadow; if (actiondownX > mScreenWidth >> 1) { shadow = mBackShadowDrawableLR; shadow.setBounds((int) (mScreenWidth + touch_down - 5), 0, (int) (mScreenWidth + touch_down + 5), mScreenHeight); } else { shadow = mBackShadowDrawableRL; shadow.setBounds((int) (touch_down - 5), 0, (int) (touch_down + 5), mScreenHeight); } shadow.draw(canvas); try { canvas.restore(); } catch (Exception e) { } }
Example #2
Source File: DynamicShapeUtils.java From dynamic-support with Apache License 2.0 | 6 votes |
/** * Returns a corner drawable which can be used for the theme preview header. * * @param width The width in dip for the drawable. * @param height The height in dip for the drawable. * @param cornerRadius The corner size in dip for the drawable. * @param color The color for the drawable. * @param topOnly {@code true} to round the top corners only. */ public static Drawable getCornerDrawableLegacy(int width, int height, float cornerRadius, @ColorInt int color, boolean topOnly) { float adjustedCornerRadius = cornerRadius; if (!topOnly) { return DynamicDrawableUtils.getCornerDrawable( width, height, adjustedCornerRadius, color); } else { adjustedCornerRadius = Math.max(0, cornerRadius - 1f); adjustedCornerRadius = DynamicUnitUtils.convertDpToPixels(adjustedCornerRadius); GradientDrawable drawable = new GradientDrawable(); drawable.setCornerRadii(new float[] { adjustedCornerRadius, adjustedCornerRadius, adjustedCornerRadius, adjustedCornerRadius, 0, 0, 0, 0 }); return DynamicDrawableUtils.getCornerDrawable(width, height, drawable, color); } }
Example #3
Source File: RxIconRoundProgressBar.java From RxTools-master with Apache License 2.0 | 6 votes |
@SuppressWarnings("deprecation") @Override protected void drawProgress(LinearLayout layoutProgress, float max, float progress, float totalWidth, int radius, int padding, int colorProgress, boolean isReverse) { GradientDrawable backgroundDrawable = createGradientDrawable(colorProgress); int newRadius = radius - (padding / 2); if (isReverse && progress != max) backgroundDrawable.setCornerRadii(new float[]{newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius, newRadius}); else backgroundDrawable.setCornerRadii(new float[]{0, 0, newRadius, newRadius, newRadius, newRadius, 0, 0}); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { layoutProgress.setBackground(backgroundDrawable); } else { layoutProgress.setBackgroundDrawable(backgroundDrawable); } float ratio = max / progress; int progressWidth = (int) ((totalWidth - ((padding * 2) + ivProgressIcon.getWidth())) / ratio); ViewGroup.LayoutParams progressParams = layoutProgress.getLayoutParams(); progressParams.width = progressWidth; layoutProgress.setLayoutParams(progressParams); }
Example #4
Source File: SettingPopup.java From eBook with Apache License 2.0 | 6 votes |
private void setCurThemeBtn() { Button usedButton = mThemeBtns[mTheme]; for (int i = 0; i < mThemeBtns.length; i++) { // 设置背景填充颜色 GradientDrawable drawable = (GradientDrawable) mThemeBtns[i].getBackground(); drawable.setColor(mPopupColors[i]); //设置边框颜色 if (mThemeBtns[i].getId() == usedButton.getId()) { int strokeColor = mStrokeColors[i]; drawable.setStroke(5, strokeColor); } else { drawable.setStroke(5, mPopupColors[i]); //未选择button的边框颜色和填充颜色一致 } } }
Example #5
Source File: AppLauncher.java From DistroHopper with GNU General Public License v3.0 | 6 votes |
protected void iconChanged () { if (! this.isInEditMode () && (this.icon != null)) { ImageView imgIcon = (ImageView) this.findViewById (R.id.imgIcon); imgIcon.setImageDrawable (this.icon.getDrawable ()); LinearLayout llBackground = (LinearLayout) this.findViewById (R.id.llBackground); if (llBackground != null && (! this.special) && this.getResources ().getBoolean (HomeActivity.theme.launcher_applauncher_backgroundcolour_dynamic)) { final SharedPreferences prefs = Preferences.getSharedPreferences(this.context, Preferences.PREFERENCES); final int avgColour = this.icon.getAverageColour(prefs.getInt (Preference.LAUNCHERICON_OPACITY.getName(), 204)); final GradientDrawable gd = (GradientDrawable) llBackground.getBackground (); gd.setColor (avgColour); } } }
Example #6
Source File: BaseTransientBottomBar.java From material-components-android with Apache License 2.0 | 6 votes |
@NonNull private Drawable createThemedBackground() { float cornerRadius = getResources().getDimension(R.dimen.mtrl_snackbar_background_corner_radius); GradientDrawable background = new GradientDrawable(); background.setShape(GradientDrawable.RECTANGLE); background.setCornerRadius(cornerRadius); int backgroundColor = MaterialColors.layer( this, R.attr.colorSurface, R.attr.colorOnSurface, getBackgroundOverlayColorAlpha()); background.setColor(backgroundColor); if (backgroundTint != null) { Drawable wrappedDrawable = DrawableCompat.wrap(background); DrawableCompat.setTintList(wrappedDrawable, backgroundTint); return wrappedDrawable; } else { return DrawableCompat.wrap(background); } }
Example #7
Source File: ScrollSlidingTextTabStrip.java From Telegram with GNU General Public License v2.0 | 6 votes |
public ScrollSlidingTextTabStrip(Context context) { super(context); selectorDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null); float rad = AndroidUtilities.dpf2(3); selectorDrawable.setCornerRadii(new float[]{rad, rad, rad, rad, 0, 0, 0, 0}); selectorDrawable.setColor(Theme.getColor(tabLineColorKey)); setFillViewport(true); setWillNotDraw(false); setHorizontalScrollBarEnabled(false); tabsContainer = new LinearLayout(context) { @Override public void setAlpha(float alpha) { super.setAlpha(alpha); ScrollSlidingTextTabStrip.this.invalidate(); } }; tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setPadding(AndroidUtilities.dp(7), 0, AndroidUtilities.dp(7), 0); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(tabsContainer); }
Example #8
Source File: ScrollSlidingTextTabStrip.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public ScrollSlidingTextTabStrip(Context context) { super(context); selectorDrawable = new GradientDrawable(GradientDrawable.Orientation.LEFT_RIGHT, null); float rad = AndroidUtilities.dpf2(3); selectorDrawable.setCornerRadii(new float[]{rad, rad, rad, rad, 0, 0, 0, 0}); selectorDrawable.setColor(Theme.getColor(tabLineColorKey)); setFillViewport(true); setWillNotDraw(false); setHorizontalScrollBarEnabled(false); tabsContainer = new LinearLayout(context) { @Override public void setAlpha(float alpha) { super.setAlpha(alpha); ScrollSlidingTextTabStrip.this.invalidate(); } }; tabsContainer.setOrientation(LinearLayout.HORIZONTAL); tabsContainer.setPadding(AndroidUtilities.dp(7), 0, AndroidUtilities.dp(7), 0); tabsContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(tabsContainer); }
Example #9
Source File: MenuDrawer.java From zhangshangwuda with Apache License 2.0 | 6 votes |
protected GradientDrawable.Orientation getDropShadowOrientation() { // Gets the orientation for the static and sliding drawer. The overlay drawer provides its own implementation. switch (mPosition) { case TOP: return GradientDrawable.Orientation.BOTTOM_TOP; case RIGHT: return GradientDrawable.Orientation.LEFT_RIGHT; case BOTTOM: return GradientDrawable.Orientation.TOP_BOTTOM; default: return GradientDrawable.Orientation.RIGHT_LEFT; } }
Example #10
Source File: BaseIndicatorBanner.java From FlycoBanner_Master with MIT License | 5 votes |
private GradientDrawable getDrawable(int color, float raduis) { GradientDrawable drawable = new GradientDrawable(); drawable.setCornerRadius(raduis); drawable.setColor(color); return drawable; }
Example #11
Source File: PageView.java From android-open-source-project-analysis with Apache License 2.0 | 5 votes |
private void drawNextPageAreaAndShadow(Canvas canvas, Bitmap bitmap) { mPath1.reset(); mPath1.moveTo(mBezierStart1.x, mBezierStart1.y); mPath1.lineTo(mBeziervertex1.x, mBeziervertex1.y); mPath1.lineTo(mBeziervertex2.x, mBeziervertex2.y); mPath1.lineTo(mBezierStart2.x, mBezierStart2.y); mPath1.lineTo(mCornerX, mCornerY); mPath1.close(); mDegrees = (float) Math.toDegrees(Math.atan2(mBezierControl1.x - mCornerX, mBezierControl2.y - mCornerY)); int leftx; int rightx; GradientDrawable mBackShadowDrawable; if (mIsRTandLB) { //左下及右上 leftx = (int) (mBezierStart1.x); rightx = (int) (mBezierStart1.x + mTouchToCornerDis / 4); mBackShadowDrawable = mBackShadowDrawableLR; } else { leftx = (int) (mBezierStart1.x - mTouchToCornerDis / 4); rightx = (int) mBezierStart1.x; mBackShadowDrawable = mBackShadowDrawableRL; } canvas.save(); try { canvas.clipPath(mPath0); canvas.clipPath(mPath1, Region.Op.INTERSECT); } catch (Exception e) { } canvas.drawBitmap(bitmap, 0, 0, null); canvas.rotate(mDegrees, mBezierStart1.x, mBezierStart1.y); mBackShadowDrawable.setBounds(leftx, (int) mBezierStart1.y, rightx, (int) (mMaxLength + mBezierStart1.y));//左上及右下角的xy坐标值,构成一个矩形 mBackShadowDrawable.draw(canvas); canvas.restore(); }
Example #12
Source File: GuidanceStreetLabelView.java From msdkui-android with Apache License 2.0 | 5 votes |
/** * Refresh the view to re-calculate the radius of view. */ public void refresh() { Drawable backgroundDrawable = getBackground(); if (backgroundDrawable instanceof GradientDrawable) { GradientDrawable drawable = (GradientDrawable) backgroundDrawable; post(() -> drawable.setCornerRadius(getHeight() >> 1)); drawable.setColorFilter(mGuidanceStreetLabelData.getBackgroundColor(), PorterDuff.Mode.SRC); } }
Example #13
Source File: GradientGridLayout.java From GradientLayout with Apache License 2.0 | 5 votes |
/** * <p>Configure the gradient background for this layout.</p> * @param startColor The start color for the gradient * @param endColor The end color for the gradient * @param orientation The orientation for the gradient {@link android.graphics.drawable.GradientDrawable.Orientation GradientDrawable.Orientation} */ public void setGradientBackgroundConfig(final int startColor, final int endColor, final GradientDrawable.Orientation orientation) { this.gradientBackground .setStartColor(startColor) .setEndColor(endColor) .setOrientation(orientation) .generate(); }
Example #14
Source File: GosDeploy.java From gokit-android with MIT License | 5 votes |
/** * 设置Button背景颜色 * * @return */ public static Drawable setButtonBackgroundColor() { GradientDrawable drawable = new GradientDrawable(); drawable.setShape(GradientDrawable.RECTANGLE); drawable.setCornerRadius(100); String ButtonColor_FromMap = infoMap.get(ButtonColor_Key).toString(); if (!TextUtils.isEmpty(ButtonColor_FromMap)) { drawable.setColor(Color.parseColor("#" + ButtonColor_FromMap)); } else { drawable.setColor(context.getResources().getColor(R.color.yellow)); } return drawable; }
Example #15
Source File: PCornerUtils.java From YImagePicker with Apache License 2.0 | 5 votes |
public static Drawable cornerDrawable(final int bgColor, float[] cornerradius, int borderwidth, int bordercolor) { final GradientDrawable bg = new GradientDrawable(); bg.setCornerRadii(cornerradius); bg.setStroke(borderwidth, bordercolor); bg.setColor(bgColor); return bg; }
Example #16
Source File: ShapeUse.java From DevUtils with Apache License 2.0 | 5 votes |
public static void shapeUse() { Button vid_btn1 = null; // 默认就设置背景色 ShapeUtils.Builder builder = new ShapeUtils.Builder(); builder.setRadiusLeft(10f).setColor(R.color.black); ViewUtils.setBackground(vid_btn1, builder.build().getDrawable()); // 设置点击效果 GradientDrawable drawable1 = ShapeUtils.newBuilder(10f, R.color.black).setStroke(5, R.color.green).build().getDrawable(); GradientDrawable drawable2 = ShapeUtils.newBuilder(10f, R.color.sky_blue).setStroke(5, R.color.gray).build().getDrawable(); ViewUtils.setBackground(vid_btn1, StateListUtils.newSelector(drawable2, drawable1)); // 设置点击 View 背景变色, 不用写 shape xml 文件 vid_btn1.setTextColor(StateListUtils.createColorStateList(R.color.red, R.color.white)); // 设置点击字体变色 // 设置渐变 View vid_view1 = null; // int[] colors = new int[]{ Color.RED, Color.BLUE, Color.GREEN }; int[] colors = new int[3]; colors[0] = ContextCompat.getColor(DevUtils.getContext(), R.color.black); colors[1] = ContextCompat.getColor(DevUtils.getContext(), R.color.sky_blue); colors[2] = ContextCompat.getColor(DevUtils.getContext(), R.color.orange); // ShapeUtils.newBuilderToGradient(GradientDrawable.Orientation.BR_TL, colors).build().setDrawable(vid_view1); GradientDrawable drawable = ShapeUtils.newBuilderToGradient(GradientDrawable.Orientation.BR_TL, colors).build().getDrawable(); // drawable.setGradientType(GradientDrawable.LINEAR_GRADIENT); // 线性渐变, 这是默认设置 // drawable.setGradientType(GradientDrawable.RADIAL_GRADIENT); // 放射性渐变, 以开始色为中心 drawable.setGradientType(GradientDrawable.SWEEP_GRADIENT); // 扫描线式的渐变 ViewUtils.setBackground(vid_view1, drawable); }
Example #17
Source File: SquareLoading.java From UGank with GNU General Public License v3.0 | 5 votes |
private void initSquare(Context context) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setColor(mSquareColor); gradientDrawable.setSize(mSquareSize, mSquareSize); gradientDrawable.setCornerRadius(mSquareCorner); for (int i = 0; i < mXCount * mYCount; i++) { ImageView image = new ImageView(context); image.setImageDrawable(gradientDrawable); addView(image); } }
Example #18
Source File: RoundHelper.java From RadioRealButton with Apache License 2.0 | 5 votes |
private static GradientDrawable getGradientDrawable(int dividerColor, int dividerRadius, Integer dividerSize) { GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{dividerColor, dividerColor}); gradient.setShape(GradientDrawable.RECTANGLE); gradient.setCornerRadius(dividerRadius); if (null != dividerSize) gradient.setSize(dividerSize, 0); return gradient; }
Example #19
Source File: DotsIndicator.java From dhis2-android-capture-app with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void addDots(int count) { for (int i = 0; i < count; i++) { View dot = LayoutInflater.from(getContext()).inflate(R.layout.dot_layout, this, false); ImageView imageView = dot.findViewById(R.id.dot); RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) imageView.getLayoutParams(); params.width = params.height = (int) dotsSize; params.setMargins((int) dotsSpacing, 0, (int) dotsSpacing, 0); ((GradientDrawable) imageView.getBackground()).setCornerRadius(dotsCornerRadius); ((GradientDrawable) imageView.getBackground()).setColor(dotsColor); final int finalI = i; dot.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (dotsClickable && viewPager != null && viewPager.getAdapter() != null && finalI < viewPager.getAdapter().getItemCount()) { viewPager.setCurrentItem(finalI, true); } } }); dots.add(imageView); addView(dot); } }
Example #20
Source File: DlQueueActivity.java From aMuleRemote with GNU General Public License v3.0 | 5 votes |
@Override public View getDropDownView(int position, View convertView, ViewGroup parent) { NavViewDropDownHolder holder; NavigationItem item = getItem(position); if (convertView == null) { convertView = View.inflate(mApp, R.layout.part_nav_dropdown, null); holder = new NavViewDropDownHolder(convertView); convertView.setTag(holder); } else { holder = (NavViewDropDownHolder) convertView.getTag(); } holder.mNavText.setText(item.getNavigationText()); if (item.isCategory()) { holder.mNavText.setTextSize(getResources().getDimension(R.dimen.abc_text_size_small_material)); holder.mNavCatBox.setVisibility(View.VISIBLE); if (holder.mNavCatBox.getDrawable() != null) { ECCategory cat = item.getCategory(); if (cat.getId() == ECCategory.NEW_CATEGORY_ID || cat.getId() == 0L) { ((GradientDrawable) holder.mNavCatBox.getDrawable()).setColor(Color.argb(0, 0, 0, 0)); } else { ((GradientDrawable) holder.mNavCatBox.getDrawable()).setColor((int) (255 << 24 | cat.getColor())); } } /*GradientDrawable backgroundGradient = (GradientDrawable) holder.mNavCatBox.getBackground(); if (backgroundGradient != null) backgroundGradient.setColor(Color.rgb((int) r, (int) g, (int) b));*/ } else { holder.mNavCatBox.setVisibility(View.GONE); holder.mNavText.setTextSize(getResources().getDimension(R.dimen.abc_text_size_subhead_material)); } return convertView; }
Example #21
Source File: RoundHelper.java From SegmentedButton with Apache License 2.0 | 5 votes |
private static GradientDrawable getGradientDrawable(int dividerColor, int dividerRadius, int dividerSize) { GradientDrawable gradient = new GradientDrawable(GradientDrawable.Orientation.BOTTOM_TOP, new int[]{dividerColor, dividerColor}); gradient.setShape(GradientDrawable.RECTANGLE); gradient.setCornerRadius(dividerRadius); gradient.setSize(dividerSize, 0); return gradient; }
Example #22
Source File: RecyclerViewBanner.java From RecyclerViewBanner with Apache License 2.0 | 5 votes |
/** * 默认指示器是一系列直径为6dp的小圆点 */ private GradientDrawable generateDefaultDrawable(int color) { GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.setSize(dp2px(6), dp2px(6)); gradientDrawable.setCornerRadius(dp2px(6)); gradientDrawable.setColor(color); return gradientDrawable; }
Example #23
Source File: Utils.java From ProjectX with Apache License 2.0 | 5 votes |
static Drawable getDefaultBackground(Context context) { final float density = context.getResources().getDisplayMetrics().density; GradientDrawable background = new GradientDrawable(); background.setSize((int) (8 * density), (int) (8 * density)); background.setColor(0x40000000); return background; }
Example #24
Source File: TwitterStaticNativeAd.java From twitter-kit-android with Apache License 2.0 | 5 votes |
private void setCallToActionStyling() { final int calculatedCTATextColor = ColorUtils.calculateCtaTextColor(ctaBackgroundColor); callToActionView.setTextColor(calculatedCTATextColor); // Setup StateListDrawable obj with two gradient drawables: // First is the selected item with lighter/darker bg color of original // Second is unselected item with the call to action background color // Also set the default ad view radius for bottomLeft and bottomRight corners final StateListDrawable stateListDrawable = new StateListDrawable(); final int adViewRadius = (int) getResources().getDimension(R.dimen.tw__ad_view_radius); final float[] ctaViewRadii = new float[]{ 0, 0, 0, 0, adViewRadius, adViewRadius, adViewRadius, adViewRadius}; final GradientDrawable selectedItem = new GradientDrawable(); selectedItem.setCornerRadii(ctaViewRadii); final int ctaPressedBgColor = ColorUtils.calculateCtaOnTapColor(ctaBackgroundColor); selectedItem.setColor(ctaPressedBgColor); stateListDrawable.addState(new int[]{android.R.attr.state_pressed}, selectedItem); final GradientDrawable unselectedItem = new GradientDrawable(); unselectedItem.setCornerRadii(ctaViewRadii); unselectedItem.setColor(ctaBackgroundColor); stateListDrawable.addState(new int[]{}, unselectedItem); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { callToActionView.setBackground(stateListDrawable); } else { callToActionView.setBackgroundDrawable(stateListDrawable); } }
Example #25
Source File: Shape.java From SelectorDrawable with Apache License 2.0 | 5 votes |
public GradientDrawable createGradientDrawable(@ColorInt int color) { GradientDrawable drawable = new GradientDrawable(); drawable.setCornerRadius(mCorner); drawable.setColor(color); drawable.setStroke(mStrokeWidth, mStrokeColor); if (mCorner == 0) { drawable.setCornerRadii(new float[]{mLeftTopCorner, mLeftTopCorner, mRightTopCorner, mRightTopCorner, mRightBottomCorner, mRightBottomCorner, mLeftBottomCorner, mLeftBottomCorner}); } return drawable; }
Example #26
Source File: AlImageAdapter.java From Applozic-Android-SDK with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { if (payloadList != null && !payloadList.isEmpty()) { ALRichMessageModel.ALPayloadModel payloadModel = payloadList.get(position); final ImageViewHolder imageViewHolder = (ImageViewHolder) holder; if (payloadModel != null) { if (alCustomizationSettings != null) { GradientDrawable bgShape = (GradientDrawable) imageViewHolder.rootLayout.getBackground(); bgShape.setColor(Color.parseColor(message.isTypeOutbox() ? alCustomizationSettings.getSentMessageBackgroundColor() : alCustomizationSettings.getReceivedMessageBackgroundColor())); bgShape.setStroke(3, message.isTypeOutbox() ? Color.parseColor(alCustomizationSettings.getSentMessageBorderColor()) : Color.parseColor(alCustomizationSettings.getReceivedMessageBackgroundColor())); } if (!TextUtils.isEmpty(payloadModel.getUrl())) { Glide.with(context) .load(payloadModel.getUrl()) .into(imageViewHolder.imageView); } else { Glide.with(context).load(R.drawable.mobicom_attachment_file).into(imageViewHolder.imageView); } if (payloadModel.getCaption() != null && !TextUtils.isEmpty(payloadModel.getCaption().trim())) { imageViewHolder.captionText.setVisibility(View.VISIBLE); imageViewHolder.captionText.setText(payloadModel.getCaption()); imageViewHolder.captionText.setTextColor(Color.parseColor(message.isTypeOutbox() ? alCustomizationSettings.getSentMessageTextColor() : alCustomizationSettings.getReceivedMessageTextColor())); } else { imageViewHolder.captionText.setVisibility(View.GONE); } } } }
Example #27
Source File: CT.java From Android-CustomToast with GNU General Public License v3.0 | 5 votes |
public static void mute2(Context context, String text) { new Builder(context, text) .shape(GradientDrawable.RECTANGLE) .backCol(Color.WHITE) .borderCol(Color.BLACK) .borderWidth(10) .textCol(Color.BLACK) .image(R.drawable.mute) .radius(50, 50, 50, 50) .show(); }
Example #28
Source File: SwipeBack.java From SwipeBack with Apache License 2.0 | 5 votes |
/** * Sets the color of the divider, if you have set the option to use a shadow * gradient as divider * * You must enable the divider by calling * {@link #setDividerEnabled(boolean)} * * @param color * The color of the divider shadow. */ public SwipeBack setDividerAsShadowColor(int color) { GradientDrawable.Orientation orientation = getDividerOrientation(); final int endColor = color & 0x00FFFFFF; GradientDrawable gradient = new GradientDrawable(orientation, new int[] { color, endColor, }); setDivider(gradient); return this; }
Example #29
Source File: StyleFragment.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
private static void setColor(ImageView image, TextView text, int color) { // set color GradientDrawable sd = (GradientDrawable) image.getDrawable(); sd.setColor(color); image.invalidate(); // set color name text.setText(getColorName(color)); }
Example #30
Source File: SuntimesUtils.java From SuntimesWidget with GNU General Public License v3.0 | 5 votes |
public static Drawable tintDrawable(GradientDrawable drawable, int fillColor, int strokeColor, int strokePixels) { if (drawable != null) { drawable.setStroke(strokePixels, strokeColor); drawable.setColor(fillColor); } return drawable; }