天天看點

解決ScrollView中listview、gridview的嵌套問題

一、listview

public class listviewforscrollview extends listview {

 public listviewforscrollview(context context) {

  super(context);

 }

 public listviewforscrollview(context context, attributeset attrs) {

  super(context, attrs);

 public listviewforscrollview(context context, attributeset attrs,

   int defstyle) {

  super(context, attrs, defstyle);

 @override

 /**

  * 重寫該方法,達到使listview适應scrollview的效果

  */

 protected void onmeasure(int widthmeasurespec, int heightmeasurespec) {

  int expandspec = measurespec.makemeasurespec(integer.max_value >> 2,

    measurespec.at_most);

  super.onmeasure(widthmeasurespec, expandspec);

}

二、gridview

public class gridviewforscrollview extends gridview {

 public gridviewforscrollview(context context) {

 public gridviewforscrollview(context context, attributeset attrs) {

 public gridviewforscrollview(context context, attributeset attrs,

  * 重寫該方法,達到使gridview适應scrollview的效果

繼續閱讀