<com.mil.example.CustomListView
android:id="@+id/villa_lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/itemImageLay"
android:fadingEdge="none"
android:scrollbars="none"/>
And below is the CustomListview classs.
public class CustomListView extends ListView {
private float lastMotionY;
public CustomListView(Context context) {
super(context);
}
public CustomListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int mode = MeasureSpec.getMode(widthMeasureSpec);
if (mode == MeasureSpec.UNSPECIFIED) {
int height = getLayoutParams().height;
if (height > 0)
setMeasuredDimension(getMeasuredWidth(), height);
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
int action = event.getAction();
float x = event.getX();
float y = event.getY();
float dy = y - lastMotionY;
switch (action) {
case MotionEvent.ACTION_DOWN:
lastMotionY = y;
break;
case MotionEvent.ACTION_MOVE:
if (Util.canScroll(this, false, (int) dy, (int) x, (int) y)) {
lastMotionY = y;
return false;
}
break;
}
return super.onInterceptTouchEvent(event);
}
}
I want to set height as match_parent
but then it's showing only the first item of the list. It shows all the items when I give the height, I am using scroll inside another scroll which is working fine.