First, look at the picture:
When you slide up and down the area marked with the red frame, change the height of the ListView,
Start
1, to obtain ListView Layoutparams:
Layoutparams params= listview.getlayoutparams ();
2, for the Relativelayout set gesture monitoring:
Mrlbus.setontouchlistener (New View.ontouchlistener () {//mrlbus is the outer layout of the red box
Float y=0;//defines a y here, receives the y-coordinate
@Override
public boolean Ontouch (View V, motionevent event) {
Switch (event.getaction ()) {
Case Motionevent.action_down:
Y=event.gety ()///////////////////////////////
Break
Case Motionevent.action_move:
Float x= event.gety ()-y;//This defines an X, meaning that each moment of the slide, the ordinate of the current moment minus the ordinate of the first finger
if (x>0| | PARAMS.HEIGHT<=250) {//If the finger is downward (x=0) or the height of the ListView is less than 250,
params.height= (int) (params.height-x); Perform a lower or elevated listview operation
if (params.height>250) {//The meaning of this step is: Assume the user is very fast up and down, may cause a height greater than 250
params.height=250;//if too high, then fixed to 250
}
}
if (params.height<0) {//The meaning of this step is: Assume the user is very fast to fall, may cause a height of less than 0, causing ListView to choose the height before sliding is the current height
params.height=0;
}
Listview.setlayoutparams (params);
Break
Case MOTIONEVENT.ACTION_UP:
Break
}
If you can help the audience, just a little bit of praise.