How to set a drawable over an image view

2019-07-24 03:31发布

I have a drawbale i want to place it in a gridView for each each image in this gridView. My drawable is a like a square but filled at the edges. So when i set this drawable as a background for the image, the image will cover the background which i dont need. I need this drawable to be in-front of the of the image not at the back.

My code look like this: enter code here

   public class ComponentAlbums extends LinearLayout 
   {
   public ClassImageLoader imageLoader;
   public ComponentAlbums(Activity activity,Context context,WallPaperHD_Album item)
{
    super(context);
    imageLoader = new ClassImageLoader(activity);

    setOrientation(LinearLayout.HORIZONTAL);
    setBackgroundColor(Color.TRANSPARENT);

    LinearLayout.LayoutParams Params = new LinearLayout.LayoutParams(120, 120);
    ImageView imageView =  new ImageView(context);
    Params.gravity = Gravity.CENTER;
    imageView.setScaleType(ScaleType.FIT_XY);
    imageView.setPadding(10, 10, 10, 10);
    //imageView.setAdjustViewBounds(true);
    imageView.setBackgroundResource(R.drawable.frame_all_albums);//this line of     code iam using to set the drawable infront of the image.

any help please.

1条回答
再贱就再见
2楼-- · 2019-07-24 03:43

A simple way to reverse the background and the actual image.

imageView.setImageResource(R.drawable.frame_all_albums);
...
imageView.setBackgroundResource(actualImageBitmap);

Hope this helps.

查看更多
登录 后发表回答