重写listView
** * ScrollView中嵌入ListView,让ListView全显示出来 * * @author reyo */ public class MyListView extends ListView { public MyListView(android.content.Context context, android.util.AttributeSet attrs) { super(context, attrs); // this.setLayoutAnimation(getAnimationController()); } /** * 设置不滚动 */ public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } protected LayoutAnimationController getAnimationController() { int duration = 300; AnimationSet set = new AnimationSet(true); Animation animation = new AlphaAnimation(0.0f, 1.0f); animation.setDuration(duration); set.addAnimation(animation); animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f); animation.setDuration(duration); set.addAnimation(animation); LayoutAnimationController controller = new LayoutAnimationController( set, 0.5f); controller.setOrder(LayoutAnimationController.ORDER_NORMAL); return controller; } }