开发者

android gallery without background

i followed the ApiDemo to create a gallery.

but i don't need the background of each item , so i marked these code:

 public ImageAdapter(Context c) {
            mContext = c;
            // See res/values/attrs.xml for the <declare-styleable> that defines
            // Gallery1.
**//            TypedArray a = obtainStyledAttributes(R.styleable.Gallery1);
//            mGalleryItemBackground = a.getResourceId(
//                    R.styleable.Gallery1_android_galleryItemBackground, 0);
//            a.recycle();**
        }


public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i =开发者_Go百科 new ImageView(mContext);

            i.setImageResource(mImageIds[position]);
            i.setScaleType(ImageView.ScaleType.FIT_XY);
            i.setLayoutParams(new Gallery.LayoutParams(48, 48));

            // The preferred Gallery item background
           **// i.setBackgroundResource(mGalleryItemBackground);**

            return i;
        }

then , i met a problem :

the default first selected item( also the first item) is bright ,

but after a start to drag , and the selected item be changed , all items looked dark.....

i don't know how to set the alpha back , let the item looks bright.......could someone help me?


Try set the cacheColorHint of your ListView. IE with

<listView android:cacheColorHint="@android:color/transparent" ...

EDIT:

Do not comment out these lines, but set the android:background in the Gallery1_android_galleryItemBackground Style to @android:color/transparent or another color you want.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜