2012-07-13 103 views
3

我有一个画廊,我有一个位图。这是代码:画廊和褪色边缘

// 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像素”

,但仍然无法正常工作我在画廊

Android的使用。任何想法为什么颜色在变化,为什么当我转到下一页时,我看到了这个优势?任何想法为什么会发生?

Edit1:我解决了一个边距问题。我将宽度增加30:i.setLayoutParams(new Gallery.LayoutParams(width+30, height)),但转到下一页后仍然颜色较浅。任何想法为什么?

回答

3

尝试以下停止图像重叠,从而消除了你的问题:

Gallery gallery= (Gallery)findViewById(R.id.gallery); 
gallery.setHorizontalFadingEdgeEnabled(false);