package com.yek.android.gap.views;

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

public class NoScrollListView extends ListView {

 public NoScrollListView(Context context, AttributeSet attrs) {
  super(context, attrs);
 }
 public NoScrollListView(Context context) {
  super(context);
 }
 @Override
 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, 0) );
   
         // here I assume that height's being calculated for one-child only, seen it in ListView's source which is actually a bad idea
         int childHeight = getMeasuredHeight() - (getListPaddingTop() + getListPaddingBottom() +  getVerticalFadingEdgeLength() * 2);
 
         int fullHeight = getListPaddingTop() + getListPaddingBottom() + childHeight*(getCount());
 
         setMeasuredDimension(getMeasuredWidth(), fullHeight);

 }
}

相关文章:

  • 2021-08-06
  • 2021-12-04
  • 2021-08-14
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-02-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案