List of usage examples for android.graphics Color argb
@ColorInt public static int argb(float alpha, float red, float green, float blue)
From source file:com.nineducks.hereader.ui.HEMessagesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { HEMessage msg = items.get(position).getHEMessage(); View view = convertView;/* w w w. ja v a2s . co m*/ ViewHolder viewHolder = null; if (view == null) { view = inflater.inflate(R.layout.item, parent, false); viewHolder = new ViewHolder(view); view.setTag(viewHolder); } if (items.get(position).isSelected()) { view.setBackgroundColor(Color.argb(0x20, 0xe0, 0xe0, 0xe0)); } else { view.setBackgroundColor(Color.argb(0xff, 0xff, 0xff, 0xff)); } viewHolder = (ViewHolder) view.getTag(); viewHolder.pubDate.setText(sdf.format(msg.getPubDate())); viewHolder.domain.setText(msg.getLink().getHost()); viewHolder.title.setText(msg.getTitle()); viewHolder.comments_count.setText(Integer.toString(msg.getCommentCount())); viewHolder.author.setText("by " + msg.getSubmitter()); viewHolder.points.setText("(" + msg.getPoints() + (msg.getPoints() == 1 ? " point)" : " points)")); return view; }
From source file:com.bartoszlipinski.recyclerviewheader2.sample.adapter.ColorItemsAdapter.java
public ColorItemsAdapter(Context context, int numberOfItems) { colors = new int[numberOfItems]; int startColor = ContextCompat.getColor(context, R.color.wisteria); int startR = Color.red(startColor); int startG = Color.green(startColor); int startB = Color.blue(startColor); int endColor = ContextCompat.getColor(context, R.color.emerald); int endR = Color.red(endColor); int endG = Color.green(endColor); int endB = Color.blue(endColor); ValueInterpolator interpolatorR = new ValueInterpolator(0, numberOfItems - 1, endR, startR); ValueInterpolator interpolatorG = new ValueInterpolator(0, numberOfItems - 1, endG, startG); ValueInterpolator interpolatorB = new ValueInterpolator(0, numberOfItems - 1, endB, startB); for (int i = 0; i < numberOfItems; ++i) { colors[i] = Color.argb(255, (int) interpolatorR.map(i), (int) interpolatorG.map(i), (int) interpolatorB.map(i)); }/*from ww w . j a v a 2 s . c o m*/ }
From source file:com.example.domiter.fileexplorer.dialog.BaseDialogFragment.java
/** * Overrides tint set with tintDrawable(). *//*w ww.j av a 2 s .c o m*/ private Drawable lightenDrawable(Drawable drawable) { if (drawable == null) { return null; } Drawable newDrawable = drawable.getConstantState().newDrawable().mutate(); newDrawable .setColorFilter(new LightingColorFilter(Color.rgb(255, 255, 255), Color.argb(200, 255, 255, 255))); return newDrawable; }
From source file:jahirfiquitiva.iconshowcase.utilities.color.ColorUtils.java
/** * Changes opacity of {@code color} to the specified {@code factor} * * @param factor which will change the opacity of the color *///from w w w . j av a 2 s . co m public static int adjustAlpha(@ColorInt int color, @FloatRange(from = 0.0, to = 1.0) float factor) { float a = Color.alpha(color) * factor; float r = Color.red(color); float g = Color.green(color); float b = Color.blue(color); return Color.argb((int) a, (int) r, (int) g, (int) b); }
From source file:org.adw.library.widgets.discreteseekbar.internal.drawable.AlmostRippleDrawable.java
private static int getModulatedAlphaColor(int alphaValue, int originalColor) { int alpha = Color.alpha(originalColor); int scale = alphaValue + (alphaValue >> 7); alpha = alpha * scale >> 8;/*from ww w . j a v a 2 s .c om*/ return Color.argb(alpha, Color.red(originalColor), Color.green(originalColor), Color.blue(originalColor)); }
From source file:org.artags.android.app.tv.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //setup ViewPager mAdapter = new TagCategoriesPagerAdapter(getFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mAdapter);/* www .j a va 2 s. c o m*/ // Sliding tabs for viewpager SlidingTabLayout slidingTab = (SlidingTabLayout) findViewById(R.id.sliding_tabs); slidingTab.setViewPager(mPager); // slidingTab.setSelectedIndicatorColors(new int[]{getResources().getColor(android.R.color.white)}); slidingTab.setCustomTabColorizer(new SlidingTabLayout.TabColorizer() { @Override public int getIndicatorColor(int position) { return getResources().getColor(R.color.accent); } @Override public int getDividerColor(int position) { return Color.argb(0, 0, 0, 0); } }); }
From source file:Main.java
public static Bitmap blur(Bitmap bitmap) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); Bitmap newBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); int pixColor = 0; int newR = 0; int newG = 0; int newB = 0; int newColor = 0; int[][] colors = new int[9][3]; for (int i = 1, length = width - 1; i < length; i++) { for (int k = 1, len = height - 1; k < len; k++) { for (int m = 0; m < 9; m++) { int s = 0; int p = 0; switch (m) { case 0: s = i - 1;// w ww.j a v a 2s. c o m p = k - 1; break; case 1: s = i; p = k - 1; break; case 2: s = i + 1; p = k - 1; break; case 3: s = i + 1; p = k; break; case 4: s = i + 1; p = k + 1; break; case 5: s = i; p = k + 1; break; case 6: s = i - 1; p = k + 1; break; case 7: s = i - 1; p = k; break; case 8: s = i; p = k; } pixColor = bitmap.getPixel(s, p); colors[m][0] = Color.red(pixColor); colors[m][1] = Color.green(pixColor); colors[m][2] = Color.blue(pixColor); } for (int m = 0; m < 9; m++) { newR += colors[m][0]; newG += colors[m][1]; newB += colors[m][2]; } newR = (int) (newR / 9F); newG = (int) (newG / 9F); newB = (int) (newB / 9F); newR = Math.min(255, Math.max(0, newR)); newG = Math.min(255, Math.max(0, newG)); newB = Math.min(255, Math.max(0, newB)); newColor = Color.argb(255, newR, newG, newB); newBitmap.setPixel(i, k, newColor); newR = 0; newG = 0; newB = 0; } } return newBitmap; }
From source file:de.dmxcontrol.model.ColorModel.java
public int getValue() { return Color.argb(255, colors[0], colors[1], colors[2]); }
From source file:com.owncloud.android.ui.ThemeableSwitchPreference.java
@RequiresApi(Build.VERSION_CODES.JELLY_BEAN) private void findSwitch(ViewGroup viewGroup) { for (int i = 0; i < viewGroup.getChildCount(); i++) { View child = viewGroup.getChildAt(i); if (child instanceof Switch) { Switch switchView = (Switch) child; int color = ThemeUtils.primaryAccentColor(); int trackColor = Color.argb(77, Color.red(color), Color.green(color), Color.blue(color)); // setting the thumb color DrawableCompat.setTintList(switchView.getThumbDrawable(), new ColorStateList(new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} }, new int[] { color, Color.WHITE })); // setting the track color DrawableCompat.setTintList(switchView.getTrackDrawable(), new ColorStateList(new int[][] { new int[] { android.R.attr.state_checked }, new int[] {} }, new int[] { trackColor, Color.parseColor("#4D000000") })); break; } else if (child instanceof ViewGroup) { findSwitch((ViewGroup) child); }/* w w w . j a v a 2 s .com*/ } }
From source file:com.commonsware.cwac.colormixer.ColorMixer.java
public int getColor() { return (Color.argb(0xFF, red.getProgress(), green.getProgress(), blue.getProgress())); }