mateslat.blogg.se

Media player android studio development
Media player android studio development











  1. #MEDIA PLAYER ANDROID STUDIO DEVELOPMENT HOW TO#
  2. #MEDIA PLAYER ANDROID STUDIO DEVELOPMENT CODE#

  • _START: Fit the image in the left and top edge of the ImageView.
  • _CENTER: Fit the image in the center of the ImageView.
  • The width and height of the image fit within the ImageView.
  • _INSIDE: Scale the image and maintain aspect ratio.
  • For a large image, this will have the effect of showing the center of the image. For a small image, this will have the effect of enlarging the entire image.
  • _CROP: Scales the image and keeps the aspect ratio until either the width of height of the image is the same as the width or height of the ImageView.
  • The complete set of ScaleTypes includes the following: For example, refers to a scale type in which the image is centered in the ImageView.Īll scale types except for FIT_XY and FIT_MATRIX maintain the aspect ratio. The options for ScaleType are defined in ImageView.ScaleType. Using ScaleType, you can have an image fill the entire ImageView, be centered in the ImageView, or be cropped and centered in the ImageView. The ScaleType defines how an image displays within the ImageView. You’ll populate an ImageView using a resource id to explore some the available features in an ImageView. To populate a Drawable object from a resource, use the getResources.getDrawable() method: Drawable myDrawable = getResources().getDrawable(R.drawable.ic_launcher) If you were working with a ShapeDrawable in code, you would use the setImageDrawable() method. In Hour 3, you used a ShapeDrawable that had been defined as a resource. In this hour, you take a closer look at using bitmap s with ImageViews. To set an ImageView to an image resource defined by R.Drawable.mainImage, you would use the following: ImageView mainImage = (ImageView) findViewById(R.id.imageView1)
  • setImageUri(): Use a URI to set the content of the ImageView.
  • setImageResource(): Use a resource id to set the content of the ImageView.
  • setImageBitmap(): Set a bitmap as the content of the ImageView.
  • media player android studio development

  • setImageDrawable(): Set a drawable as the content of the ImageView.
  • The image can be a bitmap, drawable, URI, or resource id. They differ by how the image passed is defined.

    #MEDIA PLAYER ANDROID STUDIO DEVELOPMENT CODE#

    The four projects that contain the source code for this hour are the following:įour methods are available for setting an image in an ImageView. The source code for basic ImageView examples are in the accompanying Hour21ImageView project.

    media player android studio development

    The source of the image can be a resource, a drawable, or a bitmap. An ImageView can display any drawable image.

    #MEDIA PLAYER ANDROID STUDIO DEVELOPMENT HOW TO#

    In that case, you saw how to display a drawable resource in the ImageView. Hour 6 showed how to use a simple ImageView.













    Media player android studio development