The behaviour you are experiencing is, near as I understand, expected. However, there is a setExpanded()
method which allows you to close/open the AppBarLayout
programmatically, with the option of animating the process. As such, you may be able to listen for MotionEvent.ACTION_UP
events and launch an animation to open or close the it based on how far the AppBar
has travelled from its original positions.
Edit:
Here's an implementation I just tested on an emulator running KitKat:
public class MainActivity extends AppCompatActivity {
//...
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
if (ev.getAction() == MotionEvent.ACTION_UP) {
if (appBarLayout.getY() != 0) {
//User has just finished interacting with the screen
//and the AppBar is not fully expanded. So, to close
//it with an animation...
appBarLayout.setExpanded(false, true);
}
}
return super.dispatchTouchEvent(ev);
}
//...
}