I have an application with an action bar and Tabview. There is a list inside the tab. I want the action bar to hide when the user scrolls the list and appears when the user scrolls and does it nicely. As an example, the youtube app for android does this.
I tried this code https://gist.github.com/vakrilov/6edc783b49df1f5ffda5 , but since I hide the panel, a space appears at the bottom of the screen, so in this case it is not very useful. I tried and could not change it and increase the height as I hide the panel using:
var params = userList.android.getLayoutParams(); params.height = 500; userList.android.setLayoutParams(params); userList.android.requestLayout();
Also this
var LayoutParams= android.view.ViewGroup.LayoutParams; var params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
Finally, I came out with some kind of working thing, but too suddenly there was no animation on the hide / show
var isChangingBar = false; var isBarHidden = false; userList.on("pan", function(args) { var delta = args.deltaY; console.log("deltaY: " + delta); if (!isChangingBar) { if (delta > 0 && isBarHidden === true) { isChangingBar = true; isBarHidden = false; page.actionBarHidden = false; isBarHidden = false; setTimeout(function() { isChangingBar = false; }, 250); } else if (delta < 0 && isBarHidden === false) { isChangingBar = true; page.actionBarHidden = true; isBarHidden = true; setTimeout(function() { isChangingBar = false; }, 250); } } }
Some ideas if there is a better way?
nativescript
Antonio Cueva
source share