IT. Expert System.

Android Reference

BitmapDrawable


android.graphics.drawable

Class BitmapDrawable



  • public class BitmapDrawable
    extends Drawable
    A Drawable that wraps a bitmap and can be tiled, stretched, or aligned. You can create a BitmapDrawable from a file path, an input stream, through XML inflation, or from a Bitmap object.

    It can be defined in an XML file with the <bitmap> element. For more information, see the guide to Drawable Resources.

    Also see the Bitmap class, which handles the management and transformation of raw bitmap graphics, and should be used when drawing to a Canvas.

    • Constructor Detail

      • BitmapDrawable

        @Deprecated
        public BitmapDrawable()
        Deprecated. Use BitmapDrawable(Resources) to ensure that the drawable has correctly set its target density.
        Create an empty drawable, not dealing with density.
      • BitmapDrawable

        public BitmapDrawable(Resources res)
        Create an empty drawable, setting initial target density based on the display metrics of the resources.
      • BitmapDrawable

        public BitmapDrawable(Resources res,
                      Bitmap bitmap)
        Create drawable from a bitmap, setting initial target density based on the display metrics of the resources.
      • BitmapDrawable

        @Deprecated
        public BitmapDrawable(String filepath)
        Deprecated. Use BitmapDrawable(Resources, String) to ensure that the drawable has correctly set its target density.
        Create a drawable by opening a given file path and decoding the bitmap.
      • BitmapDrawable

        public BitmapDrawable(Resources res,
                      String filepath)
        Create a drawable by opening a given file path and decoding the bitmap.
      • BitmapDrawable

        public BitmapDrawable(Resources res,
                      InputStream is)
        Create a drawable by decoding a bitmap from the given input stream.
    • Method Detail

      • getPaint

        public final Paint getPaint()
        Returns the paint used to render this drawable.
      • getBitmap

        public final Bitmap getBitmap()
        Returns the bitmap used by this drawable to render. May be null.
      • setTargetDensity

        public void setTargetDensity(Canvas canvas)
        Set the density scale at which this drawable will be rendered. This method assumes the drawable will be rendered at the same density as the specified canvas.
        Parameters:
        canvas - The Canvas from which the density scale must be obtained.
        See Also:
        Bitmap.setDensity(int), Bitmap.getDensity()
      • setTargetDensity

        public void setTargetDensity(int density)
        Set the density at which this drawable will be rendered.
        Parameters:
        density - The density scale for this drawable.
        See Also:
        Bitmap.setDensity(int), Bitmap.getDensity()
      • getGravity

        public int getGravity()
        Get the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity
        Returns:
        the gravity applied to the bitmap
      • setGravity

        public void setGravity(int gravity)
        Set the gravity used to position/stretch the bitmap within its bounds. See android.view.Gravity
        Parameters:
        gravity - the gravity
      • setAntiAlias

        public void setAntiAlias(boolean aa)
        Enables or disables anti-aliasing for this drawable. Anti-aliasing affects the edges of the bitmap only so it applies only when the drawable is rotated.
        Parameters:
        aa - True if the bitmap should be anti-aliased, false otherwise.
      • setFilterBitmap

        public void setFilterBitmap(boolean filter)
        Description copied from class: Drawable
        Set to true to have the drawable filter its bitmap when scaled or rotated (for drawables that use bitmaps). If the drawable does not use bitmaps, this call is ignored. This can improve the look when scaled or rotated, but also slows down the drawing.
        Overrides:
        setFilterBitmap 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.
        Overrides:
        setDither in class Drawable
      • getTileModeX

        public Shader.TileMode getTileModeX()
        Indicates the repeat behavior of this drawable on the X axis.
        Returns:
        Shader.TileMode#CLAMP if the bitmap does not repeat, Shader.TileMode#REPEAT or Shader.TileMode#MIRROR otherwise.
      • getTileModeY

        public Shader.TileMode getTileModeY()
        Indicates the repeat behavior of this drawable on the Y axis.
        Returns:
        Shader.TileMode#CLAMP if the bitmap does not repeat, Shader.TileMode#REPEAT or Shader.TileMode#MIRROR otherwise.
      • 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.
        Overrides:
        getChangingConfigurations in class Drawable
        Returns:
        Returns a mask of the changing configuration parameters, as defined by Configuration.
        See Also:
        Configuration
      • 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.
        Overrides:
        onBoundsChange in class Drawable
      • 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
        Parameters:
        canvas - The canvas to draw into
      • setAlpha

        public void setAlpha(int alpha)
        Description copied from class: Drawable
        Specify an alpha value for the drawable. 0 means fully transparent, and 255 means fully opaque.
        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
      • 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.
        Overrides:
        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.
        Overrides:
        getIntrinsicHeight in class Drawable


Content

Android Reference

Java basics

Java Enterprise Edition (EE)

Java Standard Edition (SE)

SQL

HTML

PHP

CSS

Java Script

MYSQL

JQUERY

VBS

REGEX

C

C++

C#

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

License.
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: 173 / 158861446. Delta: 0.04837 с