开发者

Foreground color over components on Gallery

I'm implementing a application that allows user to drag pages though a Gallery to read a newspaper.

I wrote a Adapter that returns ImageViews with some Bitmaps loaded on application.

My problem is, the first image shows perfectly, the next ones has a gray foreground that make the image looks darker. After dragging somewhere the first one also get this foreground. How can I avoid my views getting this foreground?

Now I realized that the ImageViews are getting some value on alpha channel, this is why together with my black background the images look darker. How can I avoid it?

As solicited, here it's my code:

    Gallery view = new Gallery(context);
    view.setSpacing(10);
    view.setAdapter(new PageAdapter(context, pages));
    LayoutParams params = new LayoutParams(600, 300);
    layout.addView(view, params);

And the Page Adapter

private class PageAdapter extends ArrayAdapter { private List pages;

    public PageAdapter(Context c, List<Page> pages) {
        super(c, 0);
        this.pages = pages;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        Page page = getItem(position);

        ImageView image;

        if (convertView != null)
            image = (ImageView) convertView;
        else
            image = new ImageView(context);

        image.setImageBitmap(ImageUtils.rgb(page.loadNormal()));

        return image;
    }

    public int getCount() {
        return pages.size();
    }

    public Page getItem(int position) {
        return pages.get(position);
    }
}

This ImageUtils.rgb was created to create a copy of any Bitmap into a Bitmap.RGB_586, but t开发者_StackOverflow中文版he same behaviour occurs.


You need to specify the unselectedAlpha property on the Gallery.

Either via your java (as per your example)

view.setUnselectedAlpha(1.0);

Of if you are using xml to declare the Gallery, add

android:unselectedAlpha="1.0"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜