List of usage examples for android.graphics Color alpha
@IntRange(from = 0, to = 255) public static int alpha(int color)
From source file:im.ene.ribbon.TabletActionTabView.java
private void updateLayoutOnAnimation(final float fraction, final boolean expanded) { if (expanded) { final int color = (int) evaluator.evaluate(fraction, colorInactive, colorActive); icon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); icon.setAlpha(Color.alpha(color)); } else {/*from w w w .j a va2 s .c om*/ int color = (int) evaluator.evaluate(fraction, colorActive, colorInactive); icon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP); icon.setAlpha(Color.alpha(color)); } ViewCompat.postInvalidateOnAnimation(this); }
From source file:key.secretkey.utils.EntryRecyclerAdapter.java
@Override public void onBindViewHolder(final ViewHolder holder, int position) { final PasswordItem pass = getValues().get(position); holder.name.setText(pass.toString()); if (pass.getType() == PasswordItem.TYPE_CATEGORY) { holder.typeImage.setImageResource(R.drawable.ic_folder_grey600_24dp); holder.name.setText(pass.toString() + "/"); } else {// w w w . j a v a2 s. c o m holder.typeImage.setImageResource(R.drawable.ic_action_secure); holder.name.setText(pass.toString()); } holder.type.setText(pass.getFullPathName()); if (pass.getType() == PasswordItem.TYPE_CATEGORY) { // holder.card.setCardBackgroundColor(activity.getResources().getColor(R.color.blue_grey_200)); } else { // holder.card.setCardBackgroundColor(activity.getResources().getColor(R.color.blue_grey_50)); } holder.view.setOnClickListener(getOnClickListener(holder, pass)); holder.view.setOnLongClickListener(getOnLongClickListener(holder, pass)); // after removal, everything is rebound for some reason; views are shuffled? boolean selected = selectedItems.contains(position); holder.view.setSelected(selected); if (selected) { holder.itemView.setBackgroundResource(R.color.deep_orange_200); holder.type.setTextColor(Color.BLACK); } else { holder.itemView.setBackgroundResource(Color.alpha(1)); holder.type.setTextColor(ContextCompat.getColor(activity, R.color.grey_500)); } }
From source file:android.support.v7.app.MediaRouterThemeHelper.java
public static void setVolumeSliderColor(Context context, MediaRouteVolumeSlider volumeSlider, View backgroundView) {//from w w w .j av a 2 s .com int controllerColor = getControllerColor(context, 0); if (Color.alpha(controllerColor) != 0xFF) { // Composite with the background in order not to show the underlying progress bar // through the thumb. int backgroundColor = (int) backgroundView.getTag(); controllerColor = ColorUtils.compositeColors(controllerColor, backgroundColor); } volumeSlider.setColor(controllerColor); }
From source file:im.ene.ribbon.TabletActionTabView.java
@Override protected void onLayout(final boolean changed, final int left, final int top, final int right, final int bottom) { super.onLayout(changed, left, top, right, bottom); if (null == this.icon) { this.icon = getAction().getIcon(getContext()).mutate(); this.icon.setColorFilter(isExpanded() ? colorActive : colorInactive, PorterDuff.Mode.SRC_ATOP); this.icon.setAlpha(Color.alpha(isExpanded() ? colorActive : colorInactive)); this.icon.setBounds(0, 0, iconSize, iconSize); }// w w w.j a v a 2 s . c o m if (changed) { final int w = right - left; final int h = bottom - top; final int centerX = (w - iconSize) / 2; final int centerY = (h - iconSize) / 2; icon.setBounds(centerX, centerY, centerX + iconSize, centerY + iconSize); } }
From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java
public PagerGradientTabStrip(Context context, AttributeSet attrs) { super(context, attrs); density = getResources().getDisplayMetrics().density; final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); textSize = a.getDimensionPixelSize(0, (int) (16 * density)); textColorSelected = a.getColor(1, Color.BLACK); textColorNormal = Color.argb(Color.alpha(0x80000000), Color.red(textColorSelected), Color.green(textColorSelected), Color.blue(textColorSelected)); a.recycle();/*ww w.j a v a2s . co m*/ mTextPaint.setAntiAlias(true); intervalWidth = (int) (0 * density); indicatorPadding = (int) (10 * density); indicatorHeight = (int) (3 * density); underLineHeight = (int) (2 * density); }
From source file:com.sckftr.android.app.view.InsetFrameLayout.java
public void setInsetBackgroundColor(int color) { // Resources r = getResources(); setInsetBackgroundColorRaw(/*w w w . j a v a 2 s. co m*/ Color.argb(Color.alpha(color), Color.red(color), Color.green(color), Color.blue(color))); }
From source file:com.thatkawaiiguy.meleehandbook.activity.VideoInfoActivity.java
public int adjustAlpha(int color, float factor) { int alpha = Math.round(Color.alpha(color) * factor); int red = Color.red(color); int green = Color.green(color); int blue = Color.blue(color); return Color.argb(alpha, red, green, blue); }
From source file:com.cyrilmottier.android.polaris2demo.PolylineDemoActivity.java
@Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (mMutablePolyline == null) { return;/* w ww . j a v a 2 s . c o m*/ } if (seekBar == mColorBar) { mMutablePolyline.setColor( Color.HSVToColor(Color.alpha(mMutablePolyline.getColor()), new float[] { progress, 1, 1 })); } else if (seekBar == mAlphaBar) { float[] prevHSV = new float[3]; Color.colorToHSV(mMutablePolyline.getColor(), prevHSV); mMutablePolyline.setColor(Color.HSVToColor(progress, prevHSV)); } else if (seekBar == mWidthBar) { mMutablePolyline.setWidth(progress); } }
From source file:com.doubleTwist.drawerlib.exampleapp.ExampleFragment.java
private void readDrawerValues(int drawer, ADrawerLayout adl, View v) { SeekBar seek1 = (SeekBar) v.findViewById(R.id.progress1); SeekBar seek2 = (SeekBar) v.findViewById(R.id.progress2); SeekBar seek3 = (SeekBar) v.findViewById(R.id.progress3); SeekBar seek4 = (SeekBar) v.findViewById(R.id.progress4); if (drawer == ADrawerLayout.NO_DRAWER) { float paralaxX = adl.getParalaxFactorX(); float paralaxY = adl.getParalaxFactorY(); int dimColor = adl.getDimmingColor(); float dimFraction = Color.alpha(dimColor) / 255.f; seek1.setProgress(Math.round((paralaxX - (-1)) * .5f * 1000)); seek2.setProgress(Math.round((paralaxY - (-1)) * .5f * 1000)); seek3.setProgress(Math.round(dimFraction * 1000)); } else {/* w w w .j av a 2 s . co m*/ ADrawerLayout.AnimationParameters params = adl.getAnimationParameters(drawer); float scale = params.mScale; float alpha = params.mAlpha; float rotX = params.mRotX; float rotY = params.mRotY; seek1.setProgress(Math.round(scale / .5f * 1000)); seek2.setProgress(Math.round(alpha / 1.f * 1000)); seek3.setProgress(Math.round((rotX + 45f) / 90f * 1000)); seek4.setProgress(Math.round((rotY + 45f) / 90f * 1000)); } }
From source file:com.am.pagergradienttab.view.PagerGradientTabStrip.java
private int getColor(int normalColor, int selectedColor, float offset) { int normalAlpha = Color.alpha(normalColor); int normalRed = Color.red(normalColor); int normalGreen = Color.green(normalColor); int normalBlue = Color.blue(normalColor); int selectedAlpha = Color.alpha(selectedColor); int selectedRed = Color.red(selectedColor); int selectedGreen = Color.green(selectedColor); int selectedBlue = Color.blue(selectedColor); int a = (int) Math.ceil((selectedAlpha - normalAlpha) * offset); int r = (int) Math.ceil((selectedRed - normalRed) * offset); int g = (int) Math.ceil((selectedGreen - normalGreen) * offset); int b = (int) Math.ceil((selectedBlue - normalBlue) * offset); return Color.argb(normalAlpha + a, normalRed + r, normalGreen + g, normalBlue + b); }