scrollView ListView GridView 嵌套 你要知道的

ListView GridView 嵌套 简单办法


在实际开发中,总会遇到各种各样的奇葩需求,在一些特定的情况下 展示数据不得以启动嵌套这个绝活,怎样优雅高效的实现嵌套?处理嵌套带来的各种坑?你需要掌握以下这些…

ListView/GridView 都是可以滑动的方法想在ListView Item 中展示Gridview 必须重写Gridview onMeasure(int widthMeasureSpec, int heightMeasureSpec) 方法 测量Gridview 的高度

import android.content.Context;
import android.util.AttributeSet;
import android.widget.GridView;

public class MyGridView extends GridView {

  public MyGridView(Context context, AttributeSet attrs) {
    super(context, attrs);
  }

  public MyGridView(Context context) {
    super(context);
  }

  public MyGridView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
  }

  @Override
  public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {

    int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
        MeasureSpec.AT_MOST);
    super.onMeasure(widthMeasureSpec, expandSpec);
  }
}

猜你喜欢

转载自blog.csdn.net/silencezmz/article/details/78811386