IT. Expert System.

Android Reference


Class ShapeDrawable

  • Direct Known Subclasses:

    public class ShapeDrawable
    extends Drawable
    A Drawable object that draws primitive shapes. A ShapeDrawable takes a Shape object and manages its presence on the screen. If no Shape is given, then the ShapeDrawable will default to a RectShape.

    This object can be defined in an XML file with the <shape> element.

    Developer Guides

    For more information about how to use ShapeDrawable, read the Canvas and Drawables document. For more information about defining a ShapeDrawable in XML, read the Drawable Resources document.

    • Constructor Detail

      • ShapeDrawable

        public ShapeDrawable()
        ShapeDrawable constructor.
      • ShapeDrawable

        public ShapeDrawable(Shape s)
        Creates a ShapeDrawable with a specified Shape.
        s - the Shape that this ShapeDrawable should be
    • Method Detail

      • getShape

        public Shape getShape()
        Returns the Shape of this ShapeDrawable.
      • setShape

        public void setShape(Shape s)
        Sets the Shape of this ShapeDrawable.
      • setShaderFactory

        public void setShaderFactory(ShapeDrawable.ShaderFactory fact)
        Sets a ShaderFactory to which requests for a Shader object will be made.
        fact - an instance of your ShaderFactory implementation
      • getPaint

        public Paint getPaint()
        Returns the Paint used to draw the shape.
      • setPadding

        public void setPadding(int left,
                      int top,
                      int right,
                      int bottom)
        Sets padding for the shape.
        left - padding for the left side (in pixels)
        top - padding for the top (in pixels)
        right - padding for the right side (in pixels)
        bottom - padding for the bottom (in pixels)
      • setPadding

        public void setPadding(Rect padding)
        Sets padding for this shape, defined by a Rect object. Define the padding in the Rect object as: left, top, right, bottom.
      • setIntrinsicWidth

        public void setIntrinsicWidth(int width)
        Sets the intrinsic (default) width for this shape.
        width - the intrinsic width (in pixels)
      • setIntrinsicHeight

        public void setIntrinsicHeight(int height)
        Sets the intrinsic (default) height for this shape.
        height - the intrinsic height (in pixels)
      • getIntrinsicWidth

        public int getIntrinsicWidth()
        Description copied from class: Drawable
        Return the intrinsic width of the underlying drawable object. Returns -1 if it has no intrinsic width, such as with a solid color.
        getIntrinsicWidth in class Drawable
      • getIntrinsicHeight

        public int getIntrinsicHeight()
        Description copied from class: Drawable
        Return the intrinsic height of the underlying drawable object. Returns -1 if it has no intrinsic height, such as with a solid color.
        getIntrinsicHeight in class Drawable
      • getPadding

        public boolean getPadding(Rect padding)
        Description copied from class: Drawable
        Return in padding the insets suggested by this Drawable for placing content inside the drawable's bounds. Positive values move toward the center of the Drawable (set Rect.inset). Returns true if this drawable actually has a padding, else false. When false is returned, the padding is always set to 0.
        getPadding in class Drawable
      • onDraw

        protected void onDraw(Shape shape,
                  Canvas canvas,
                  Paint paint)
        Called from the drawable's draw() method after the canvas has been set to draw the shape at (0,0). Subclasses can override for special effects such as multiple layers, stroking, etc.
      • draw

        public void draw(Canvas canvas)
        Description copied from class: Drawable
        Draw in its bounds (set via setBounds) respecting optional effects such as alpha (set via setAlpha) and color filter (set via setColorFilter).
        Specified by:
        draw in class Drawable
        canvas - The canvas to draw into
      • getChangingConfigurations

        public int getChangingConfigurations()
        Description copied from class: Drawable
        Return a mask of the configuration parameters for which this drawable may change, requiring that it be re-created. The default implementation returns whatever was provided through Drawable.setChangingConfigurations(int) or 0 by default. Subclasses may extend this to or in the changing configurations of any other drawables they hold.
        getChangingConfigurations in class Drawable
        Returns a mask of the changing configuration parameters, as defined by Configuration.
        See Also:
      • setAlpha

        public void setAlpha(int alpha)
        Set the alpha level for this drawable [0..255]. Note that this drawable also has a color in its paint, which has an alpha as well. These two values are automatically combined during drawing. Thus if the color's alpha is 75% (i.e. 192) and the drawable's alpha is 50% (i.e. 128), then the combined alpha that will be used during drawing will be 37.5% (i.e. 96).
        Specified by:
        setAlpha in class Drawable
      • setColorFilter

        public void setColorFilter(ColorFilter cf)
        Description copied from class: Drawable
        Specify an optional colorFilter for the drawable. Pass null to remove any filters.
        Specified by:
        setColorFilter in class Drawable
      • setDither

        public void setDither(boolean dither)
        Description copied from class: Drawable
        Set to true to have the drawable dither its colors when drawn to a device with fewer than 8-bits per color component. This can improve the look on those devices, but can also slow down the drawing a little.
        setDither in class Drawable
      • onBoundsChange

        protected void onBoundsChange(Rect bounds)
        Description copied from class: Drawable
        Override this in your subclass to change appearance if you recognize the specified state.
        onBoundsChange in class Drawable
      • inflateTag

        protected boolean inflateTag(String name,
                         Resources r,
                         XmlPullParser parser,
                         AttributeSet attrs)
        Subclasses override this to parse custom subelements. If you handle it, return true, else return super.inflateTag(...).
      • mutate

        public Drawable mutate()
        Description copied from class: Drawable
        Make this drawable mutable. This operation cannot be reversed. A mutable drawable is guaranteed to not share its state with any other drawable. This is especially useful when you need to modify properties of drawables loaded from resources. By default, all drawables instances loaded from the same resource share a common state; if you modify the state of one instance, all the other instances will receive the same modification. Calling this method on a mutable Drawable will have no effect.
        mutate in class Drawable
        This drawable.
        See Also:
        Drawable.ConstantState, Drawable.getConstantState()


Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)





Java Script








Design patterns

RFC (standard status)

RFC (proposed standard status)

RFC (draft standard status)

RFC (informational status)

RFC (experimental status)

RFC (best current practice status)

RFC (historic status)

RFC (unknown status)

IT dictionary

All information of this service is derived from the free sources and is provided solely in the form of quotations. This service provides information and interfaces solely for the familiarization (not ownership) and under the "as is" condition.
Copyright 2016 © ELTASK.COM. All rights reserved.
Site is optimized for mobile devices.
Downloads: 214 / 158863247. Delta: 0.05239 с