Android PorterDuffColorFilter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android PorterDuffColorFilter class.

This code example shows how to use the following methods:
     * @param filter The filter color to be applied using SRC_OVER mode. 
     */ 
    public void setColorWithFilter(int color, int filter) {
        mColorPaint = new Paint(mPaint);
        mColorPaint.setColor(color);
        mColorPaint.setColorFilter(new PorterDuffColorFilter(filter, PorterDuff.Mode.SRC_OVER));
    } 
 
    /** 
     * Set the alpha for the linear gradient used with the bitmap's shader. 
     * 
     * @param startAlpha The starting alpha (0..255) value to be applied to the LinearGradient. 
     * @param startAlpha The ending alpha (0..255) value to be applied to the LinearGradient. 
     */ 
    public void setAlpha(int startAlpha, int endAlpha) {
        mStartColor = startAlpha << 24;
        mEndColor = endAlpha << 24;
        initializeBitmapShader(); 
    } 
 
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        ((ViewGroup) findViewById(R.id.list1).getParent()).setChildrenLayersEnabled(true);
    } 
     
    private void setupList(int listId) {
        final Paint p = new Paint();
        p.setColorFilter(new PorterDuffColorFilter(0xff00ff00, PorterDuff.Mode.MULTIPLY));
 
        final ListView list = (ListView) findViewById(listId);
        list.setAdapter(new SimpleListAdapter(this));
        list.setLayerType(View.LAYER_TYPE_HARDWARE, p);
    } 
 
    private static class SimpleListAdapter extends ArrayAdapter<String> {
        public SimpleListAdapter(Context context) {
            super(context, android.R.layout.simple_list_item_1, DATA_LIST);
        } 
 
        @Override 
        public View getView(int position, View convertView, ViewGroup parent) {
            TextView v = (TextView) super.getView(position, convertView, parent);
Full Snippet Info
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		super.onRestart(); 
		 
		// Set up the view 
		int x = mSharedPrefs.getInt("theme_color", -1);
		if(x != -1)
			ThemeTools.setColorOverlay(new PorterDuffColorFilter(x, 
					PorterDuff.Mode.MULTIPLY), background, header);
	} 
} 
Full Snippet Info
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
		toast.setDuration( duration );
		toast.setView( layout );
		toast.show();
	} 
	 
	static PorterDuffColorFilter mWhiteMultiplyFilter = new PorterDuffColorFilter( 0xFFFFFFFF, Mode.MULTIPLY );
 
	/** 
	 * Draw folder icon. 
	 *  
	 * @param folder 
	 *           the folder 
	 * @param icon 
	 *           the icon 
	 * @param icon_new 
	 *           the icon_new 
	 * @return the drawable 
	 */ 
	public static Drawable drawFolderIcon( Drawable folder, Drawable icon, float ratio ) {
 
Full Snippet Info
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    public DragListView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        // µ±Ä³¸öitem±»ÍÏקʱ£¬½«ÆäÑÕÉ«¸Ä±ä 
        final int srcColor = context.getResources().getColor(Color.GREEN);
        mPaint.setColorFilter(new PorterDuffColorFilter(srcColor, PorterDuff.Mode.SRC_ATOP));
        mScaledTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    } 
 
    @Override 
    protected void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        if (mDragging && mDragBitmap != null) {
            final int scrollX = getScrollX();
            final int scrollY = getScrollY();
            float left = scrollX + mLastMotionX - mTouchOffsetX - mBitmapOffsetX;
            float top = scrollY + mLastMotionY - mTouchOffsetY - mBitmapOffsetY;
            canvas.drawBitmap(mDragBitmap, left, top, mPaint);
        } 
    } 
Full Snippet Info
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
                Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(dest);
        final Paint paint = new Paint();
 
        // Overlay the selected color and set the imageview 
        paint.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_ATOP));
        c.drawBitmap(src, 0, 0, paint);
        return dest;
    } 
 
    public static Bitmap getBitmapFromResource(Resources res, int resId, int density) {
        if (density == 0) {
            if (D) Log.d(TAG, "Decoding resource id = " + resId + " for default density");
            return BitmapFactory.decodeResource(res, resId);
        } 
 
        if (D) Log.d(TAG, "Decoding resource id = " + resId + " for density = " + density);
        Drawable d = res.getDrawableForDensity(resId, density);
        if (d instanceof BitmapDrawable) {
            BitmapDrawable bd = (BitmapDrawable) d;
Full Snippet Info
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    init(context);
  } 
   
  private Paint makePaint( int color ) {
    Paint paint = new Paint();
    paint.setColorFilter( new PorterDuffColorFilter( 0xff000000 | color, PorterDuff.Mode.SRC_ATOP ));
    return paint;
  } 
 
  private void init(Context context) {
    silhouette = BitmapFactory.decodeResource(context.getResources(), R.drawable.battery_silhouette);
    plug = BitmapFactory.decodeResource(context.getResources(), R.drawable.power_plug);
    green = makePaint( 0x00ff00 );
    yellow = makePaint( 0xffff00 );
    red = makePaint( 0xff0000 );
    gray = makePaint( 0x808080 );
 
    levelPercent = 0;
    pluggedIn = false;
  } 
Full Snippet Info
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
       greenBar.getProgress(), 
       blueBar.getProgress());
      
     PorterDuff.Mode mode = optMode[modeSpinner.getSelectedItemPosition()];
      
     PorterDuffColorFilter porterDuffColorFilter = new PorterDuffColorFilter(srcColor, mode);
     iv.setColorFilter(porterDuffColorFilter);
      
     colorInfo.setText(
       "srcColor = #" + Integer.toHexString(srcColor) +"\n" +
       "mode = " + String.valueOf(mode.toString()) + " of total " + String.valueOf(optMode.length) + " modes.");
   
    } 
 
} 
Full Snippet Info
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	    init(context);
	  } 
	  
	  private Paint makePaint( int color ) {
	    Paint paint = new Paint();
	    paint.setColorFilter( new PorterDuffColorFilter( 0xff000000 | color, PorterDuff.Mode.SRC_ATOP ));
	    return paint;
	  } 
	  private void init(Context context) {
	    silhouette = BitmapFactory.decodeResource(context.getResources(), R.drawable.battery_silhouette);
	    plug = BitmapFactory.decodeResource(context.getResources(), R.drawable.battery_charging);
	    green = makePaint( 0x00ff00 );
	    yellow = makePaint( 0xffff00 );
	    red = makePaint( 0xff0000 );
	    gray = makePaint( 0x808080 );
	    levelPercent = 0;
	    pluggedIn = false;
	  } 
	  public void setBatteryPercent(float percent) {
	    levelPercent = percent;
Full Snippet Info
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
     * @param filter The filter color to be applied using SRC_OVER mode. 
     */ 
    public void setColorWithFilter(int color, int filter) {
        mColorPaint = new Paint(mPaint);
        mColorPaint.setColor(color);
        mColorPaint.setColorFilter(new PorterDuffColorFilter(filter, PorterDuff.Mode.SRC_OVER));
    } 
 
    /** 
     * Set the alpha for the linear gradient used with the bitmap's shader. 
     * 
     * @param startAlpha The starting alpha (0..255) value to be applied to the LinearGradient. 
     * @param startAlpha The ending alpha (0..255) value to be applied to the LinearGradient. 
     */ 
    public void setAlpha(int startAlpha, int endAlpha) {
        mStartColor = startAlpha << 24;
        mEndColor = endAlpha << 24;
        initializeBitmapShader(); 
    } 
 
Full Snippet Info
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related Android PorterDuffColorFilter Questions & Answers:

See Code Examples for Android PorterDuffColorFilter Methods: