画廊和褪色的边缘

时间:2012-07-13 12:40:02

标签: android android-layout gallery

我有一个画廊,我有一个位图。这是代码:

    // Bitmap snoop = BitmapFactory.decodeResource(mContext.getResources(), mImageIds[position]);
   // i.setImageResource(mImageIds[position]);
   // i.setScaleType(ImageView.ScaleType.FIT_XY);
        BitmapFactory.Options options = new BitmapFactory.Options();

        // will results in a much smaller image than the original
        Bitmap b = BitmapFactory.decodeFile("/sdcard/DinEgen/"+name.get(position), options);
        Bitmap img = Bitmap.createScaledBitmap( b, width, height, true );
         b.recycle();
    i.setImageBitmap(img);
    //i.setBackgroundResource(mGalleryItemBackground);
    i.setGallery(g);
    i.setLayoutParams(new Gallery.LayoutParams(width, height));

    return i;

当我开始申请时,一切看起来都不错。就像在图片上: enter image description here

当我进入下一页时,一切看起来都很糟糕: enter image description here

颜色较浅,左侧是边缘,颜色好。当我背部颜色也更亮而且这个边缘在右侧。我在画廊中使用

机器人:fadingEdge = “无”     机器人:fadingEdgeLength = “0像素”

但仍然无效。知道为什么颜色会发生变化以及为什么当我进入下一页时我看到了这个优势?有什么想法会发生这种情况吗?

Edit1:我解决了边距问题。我在i.setLayoutParams(new Gallery.LayoutParams(width+30, height))中加宽了30,但是在转到下一页后,颜色仍然较浅。知道为什么吗?

1 个答案:

答案 0 :(得分:3)

尝试以下操作以停止图像重叠,从而消除您的问题:

Gallery gallery= (Gallery)findViewById(R.id.gallery);
gallery.setHorizontalFadingEdgeEnabled(false);
相关问题