如何设置一个可绘制在图像视图 [英] How to set a drawable over an image view

查看:126
本文介绍了如何设置一个可绘制在图像视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个drawbale我想将其放置在对该GridView的每个每个图像的GridView。
我的提拉是类似一个方形而是填充在边缘。所以,当我设置绘制作为图像的背景,图像将涵盖我不需要的背景。
我需要这个绘制是在前面的形象不是在后面。

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.

我的code是这样的:
    在此输入code

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.

推荐答案

一个简单的方法来扭转背景和实际图像。

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

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

希望这有助于。

这篇关于如何设置一个可绘制在图像视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆