Android Gallery防止抖动

今天在做一个循环滚动的Gallery时当图片为两张的时候一直抖动,最终程序崩溃,这个问题纠结了好久,在stackoverflow中也找了好久,没有什么有效的办法,一般都是设置什么wrapcontent到fillparent的,最后同事的一个程序是好的,请教了一下,居然好了。下面是解决问题的方案:

  1. <FrameLayout 
  2.                 android:id="@+id/news_detail_content_layout" 
  3.                 android:layout_width="fill_parent" 
  4.                 android:layout_height="wrap_content" 
  5.                 android:orientation="vertical" > 
  6.  
  7.                 <com.hoge.android.wuxiwireless.ui.view.HomeGallery 
  8.                     android:id="@+id/news_detail_content_gallery" 
  9.                     android:layout_width="fill_parent" 
  10.                     android:layout_height="wrap_content" 
  11.                     android:animationDuration="100" 
  12.                     android:background="@drawable/default_bg2" 
  13.                     android:fadingEdge="none" 
  14.                     android:spacing="0.0dip" /> 
  15.             </FrameLayout> 

原因不多说了,bug

在你的Gallery外面套上一层FrameLayout