Search code examples
androiddrawableandroid-gallery

Gallery image background


I set a background image in android gallery with:

ga.setBackgroundDrawable(R.drawable.myimage);

and it's work.
How can i set the position of background image in android gallery ?

DETAILS:
I have a semi-trasparent gallery of image over a background image.
So I need to center the image in the gallery over the background image.
NOT full width image.

If it's impossible to do, how can i set an image over a selected image from gallery ?


Solution

  • you can set the background image since you know the selected image in the gallery using gallery.getSelectedItemPosition()

    Using this position you should be able to get the image from the images list that you provide to the gallery's adapter

    for example if it's a list of drawables:

     imageView.setImageDrawable(listDrawables.get(gallery.getSelectedItemPosition()));
    

    as for centering part you should just set

     <ImageView
          ...
          android:scaleType="centerInside"
          ... />