Android ColorDrawable - 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 ColorDrawable class.

This code example shows how to use the following methods:draw
    private final Paint paint = new Paint();
 
    public IcsColorDrawable(ColorDrawable drawable) {
        Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
        Canvas c = new Canvas(bitmap);
        drawable.draw(c);
        this.color = bitmap.getPixel(0, 0);
        bitmap.recycle();
    } 
 
    public IcsColorDrawable(int color) {
        this.color = color;
    } 
 
    @Override public void draw(Canvas canvas) {
        if ((color >>> 24) != 0) {
            paint.setColor(color);
            canvas.drawRect(getBounds(), paint);
        } 
    } 
7
CodeRank
This code example shows how to use the following methods:
	private static final int NOT_SET = -1;
	private int alpha = NOT_SET;
 
	public TiBackgroundDrawable() 
	{ 
		background = new ColorDrawable(Color.TRANSPARENT);
		innerRect = new RectF();
	} 
 
	@Override 
	public void draw(Canvas canvas)
	{ 
		if (background != null) {
			background.setBounds((int) innerRect.left, (int) innerRect.top, (int) innerRect.right, (int) innerRect.bottom);
		} 
 
		canvas.save();
 
		if (background != null) {
			if (alpha > NOT_SET) {
6
CodeRank
This code example shows how to use the following methods:
    public void setLabel(int resId) {
        setLabel(getResources().getText(resId));
    } 
 
    public void setSelectionHandlerColor(int color) {
        setSelectionHandlerDrawable(new ColorDrawable(color));
    } 
 
    public void setSelectionHandlerColorResource(int resId) {
        setSelectionHandlerColor(getResources().getColor(resId));
    } 
 
    @SuppressWarnings("deprecation") 
    public void setSelectionHandlerDrawable(Drawable drawable) {
        selectionHandler.setBackgroundDrawable(drawable);
    } 
 
    public void setSelectionHandlerDrawableResource(int resId) {
        setSelectionHandlerDrawable(getResources().getDrawable(resId));
    } 
7
CodeRank
This code example shows how to use the following methods:getColor
	} 
 
	@TargetApi(Build.VERSION_CODES.HONEYCOMB)
	private int getColorFromColorDrawableHC(ColorDrawable colorDrawable)
	{ 
		return colorDrawable.getColor();
	} 
 
	public void setBackgroundColor(int value)
	{ 
		if (view == null) {
			Log.w(TAG, "Wrapped view is null. Cannot set background color.");
			return; 
		} 
		view.setBackgroundColor(value);
	} 
 
} 
7
CodeRank
This code example shows how to use the following methods:setBackgroundDrawable
    float mSeekValue = .5f;
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
        SeekBar slider = new SeekBar(this);
        LinearLayout container = new LinearLayout(this);
        container.setOrientation(LinearLayout.VERTICAL);
        setContentView(container);
 
        container.addView(slider);
        slider.setMax(100);
        slider.setProgress(50);
        FrameLayout frame = new FrameLayout(this);
        final RenderingView gpuView = new RenderingView(this, Color.GREEN);
        frame.addView(gpuView);
        final RenderingView swView = new RenderingView(this, Color.RED);
        swView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frame.addView(swView);
7
CodeRank
This code example shows how to use the following methods:
        if (contentView == null) {
            throw new IllegalStateException("You need to set the content view using the setContentView method");
        } 
 
        // Replaces the background of the popup with a cleared background 
        setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
 
        final int[] loc = mLocation;
        anchor.getLocationOnScreen(loc);
        mRect.set(loc[0], loc[1], loc[0] + anchor.getWidth(), loc[1] + anchor.getHeight());
 
        if (mIsDirty) {
            clearQuickActions(); 
            populateQuickActions(mQuickActions);
        } 
 
        onMeasureAndLayout(mRect, contentView);
 
        if ((mPrivateFlags & MEASURE_AND_LAYOUT_DONE) != MEASURE_AND_LAYOUT_DONE) {
            throw new IllegalStateException("onMeasureAndLayout() did not set the widget specification by calling"
7
CodeRank
This code example shows how to use the following methods:
This code example shows how to use the following methods:setBackgroundDrawable
    float mSeekValue = .5f;
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
        SeekBar slider = new SeekBar(this);
        LinearLayout container = new LinearLayout(this);
        container.setOrientation(LinearLayout.VERTICAL);
        setContentView(container);
 
        container.addView(slider);
        slider.setMax(100);
        slider.setProgress(50);
        FrameLayout frame = new FrameLayout(this);
        final RenderingView gpuView = new RenderingView(this, Color.GREEN);
        frame.addView(gpuView);
        final RenderingView swView = new RenderingView(this, Color.RED);
        swView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frame.addView(swView);
7
CodeRank
This code example shows how to use the following methods:
        super(context, attrs);
    } 
 
    public void setChecked(boolean checked) {
        mChecked = checked;
        setBackgroundDrawable(checked ? new ColorDrawable(0xff0000a0) : null);
    } 
 
    public boolean isChecked() { 
        return mChecked;
    } 
 
    public void toggle() { 
        setChecked(!mChecked);
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:
 
  @SmallTest 
  public void testGetDrawableDrawable() { 
    // Make sure that the resource whose type is "drawable" should be loaded by resources directly. 
    Resources resources = createMock(MockResources.class);
    Drawable drawable = new ColorDrawable(Color.WHITE);
    expect(resources.getResourceTypeName(1)).andReturn("drawable");
    expect(resources.getDrawable(1)).andReturn(drawable);
    replayAll(); 
 
    MozcDrawableFactory factory = new MozcDrawableFactory(resources);
    assertSame(drawable, factory.getDrawable(1));
 
    verifyAll(); 
  } 
 
  @SmallTest 
  public void testEmojiDrawable() { 
    // Try to parse all emoji Drawable. 
    Resources resources = getInstrumentation().getTargetContext().getResources();
6
CodeRank

Related Android ColorDrawable Questions & Answers:

See Code Examples for Android ColorDrawable Methods: