开发者

Android setUnselectedAlpha() does not reset to full opacity on selected item in Gallery view

As the title says, if I use setUnselectedAlpha() on my gallery, the selected items never return to full opacity. I found some of the same questions online and the only answer I found was that it had to be usin开发者_JAVA技巧g a style to have the setUnselectedAlpha() work properly. I hope this is not the case because I don't want a background or border in my gallery. Anyway I tried that solution and it is still not working. Has anyone ran into this before and is there a solution?

Thank you!


Works fine when u add this, to your gallery:

style="android:galleryItemBackground"

so the code:

   <Gallery style="android:galleryItemBackground"
    android:id="@+id/gallery"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="top" android:layout_marginTop="50dip"/>

and then

g.setUnselectedAlpha(0.3f);

then on getview:

public View getView(int position, View convertView, ViewGroup parent) {
    ImageView i = new ImageView(mContext);

    position= getPosition(position); 

    i.setImageBitmap(images.elementAt(position));
    i.setScaleType(ImageView.ScaleType.FIT_CENTER);

    i.setBackgroundColor(R.color.chatblue); //add some background, and it work! 


    return i;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜