Gallery控件中的这个android:unselectedAlpha属性,是说当图片未处于中间位置时的清晰度,处于中间的那副图片永远都是清晰度为1的,我现在遇到的问题是第一次进入到应用,gallery中中间那幅图是为1,但是当我将其移出中间位置,他就变为android:unselectedAlpha属性中设的值,这些都是正常现象,问题是 之后所有的图片都是android:unselectedAlpha中的值,再也不会出现清晰度为1的图片,求教~

解决方案 »

  1.   

    gallery = (Gallery) LayoutInflater.from(getApplicationContext())
    .inflate(R.layout.activity_home_gallery, null);
    gallery.setAdapter(new GalleryImageAdapter(getApplicationContext(),
    resIds));
    // 去掉阴影
    gallery.setFadingEdgeLength(0);
    // 当前显示第1000张图片
    gallery.setSelection(1000);
    list = (ListView) this.findViewById(android.R.id.list);
    // 设置headerView没有list的Item点击事件
    list.addHeaderView(gallery, null, false);
    下面是XMl:
    <?xml version="1.0" encoding="utf-8"?>
    <Gallery xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/gallery" 
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" 
        android:paddingTop="5dp"
        android:paddingBottom="5dp"
        android:spacing="2.7dp" 
        android:unselectedAlpha="0.6"
        android:focusable="true"
        android:background="@drawable/list_item_bg_selector"
         />
      

  2.   

    gallery = (Gallery) LayoutInflater.from(getApplicationContext())
    .inflate(R.layout.activity_home_gallery, null);
    gallery.setAdapter(new GalleryImageAdapter(getApplicationContext(),
    resIds));
    // 去掉阴影
    gallery.setFadingEdgeLength(0);
    // 当前显示第1000张图片
    gallery.setSelection(1000);
    list = (ListView) this.findViewById(android.R.id.list);
    // 设置headerView没有list的Item点击事件
    list.addHeaderView(gallery, null, false);这段代码你是在哪里调的?
    create?
    还是什么函数
    好像是update Gallery的逻辑有误你试试看在移动的时候用log看一下select的item是哪一个
      

  3.   

    我的代码也出现这种情况,哪位兄弟给指点下
    布局
    <Gallery android:id="@+id/gallery_ad" android:layout_width="fill_parent"
    android:layout_height="85dip" android:spacing="5dip"
    android:fadingEdge="none" android:keepScreenOn="true"
    android:unselectedAlpha="0.5" android:paddingTop="5dip" />代码
                ArrayList<Integer> listImage = new ArrayList<Integer>();
                listImage.add(R.drawable.ad);
                listImage.add(R.drawable.ad2);
                listImage.add(R.drawable.ad3);
                listImage.add(R.drawable.ad);
                listImage.add(R.drawable.ad2);
    //            ArrayList<Integer> listmodle =
    //                            msg.getData().getIntegerArrayList("data");
                            //Gallery适配器
                            AdGalleryAdapter imageAdapter =
                                new AdGalleryAdapter(WeiBaActivity.this, listImage);
                            adGallery.setAdapter(imageAdapter);适配器
    public class AdGalleryAdapter extends BaseAdapter
    {
        Context context;
        
        List<Integer> list;
        
        public AdGalleryAdapter(Context context, List<Integer> list)
        {
            this.context = context;
            this.list = list;
        }
        
        public Object getItem(int position)
        {
            return position;
        }
        
        public int getCount()
        {
            return list.size();
        }
        
        public long getItemId(int position)
        {
            return position;
        }
        
        public View getView(int position, View convertView, ViewGroup parent)
        {
            ImageView image = new ImageView(context);
            image.setScaleType(ScaleType.FIT_XY);
            image.setLayoutParams(new Gallery.LayoutParams(200,
                android.widget.Gallery.LayoutParams.FILL_PARENT));
            image.setImageResource(list.get(position));
            
            return image;
        }
        
    }帮忙看看,谢谢
      

  4.   

    据说使用了android:galleryItemBackground会好
      

  5.   

    据说使用了android:galleryItemBackground会好
      

  6.   

    我确认了,只要把你Gallery的每个子View都设置背景图或者背景色就OK了,设置透明背景也可以。应该是Android的一个bug,不设置背景不刷新。