Youtube like scrolling behaviour - java

I have Frame Layout(Each Containing RecyclerView), Bottom Navigation Bar and a Custom toolbar.
I want that for each Fragment whenever their is some upward scrolling event occurs, my toolbar should hide and whenever comes back whenever down scrolling event occurs.
Can you help to do this as I am new to Android Programming.

Check This or This.
These questions answer the problem of hiding the bottom bar.

Related

Add Google Map to a button of bottom navigation bar

I try to put the bottom navigation bar under Google Map and I can't. When I tap the second button of navigation bar I want to open google map fragment but the bar stays at the bottom. Does anyone know how it can be done?
Here is an example of exactly what I want:
My app uses a bottom navigation layout and loads up three fragments (on one of them is a google map fragment), hence the bottom navigation menu stays there for all the three fragment of the app!
If you want to have a screen where the bottom navigation isn't present, why not use an activity with a layout without a bottom navigation view for that screen ? The user will just navigate back to the previous activity when the job is done.

Android : hide/show footer/header as scrolling scrollview down/up

I am trying to implement a way to have my footer slide away down and my header to slide away up while user scrolls down the scrollview.
And vice-versa, as the user scrolls up the scollview, I want my footer to slide in from the bottom and the header slide in form the top.
Regarding the animation, I have found this good library https://github.com/daimajia/AndroidViewAnimations that comes with a lot of nice animations.
The closest example for what I am looking for, is the default Android Twitter application that makes it's footer disappear as the user scrolls his timeline down and makes it reappear as the user scrolls up.
By header, I am not talking about the Android Toolbar (op AppBar or whatever). It's a customed-made UI element that I want to animate while the user scrolls.
Same thing goes for the footer : it's a customed-made UI element.
While looking for solutions, I stumble upon this answer https://stackoverflow.com/a/28712465/3535408 but it does not work.
Indeed, placing a Log.d inside the ifand else if shows that a simple touch with my finger triggers both a MotionEvent.ACTION_DOWN and a MotionEvent.ACTION_UP event. The same applies as I am sliding my finger up/down making the scrollview scrolls up/down : both events are triggered at the end when I stop touching the scrollview.
Is there a way to improve this solution ? Because as of now, as both MotionEvents are triggered, both animations are also triggered so the result is quite horrible.
Thanks !
An easy way to achieve that would be the following:
place the listview, the header and the footer inside a RelativeLayout
align the header with parent's top
align the footer with parent's bottom
add an empty header and footer to the listview with the same heights
catch the scrolling events on your listview and change the footer and/or header's translationY accordingly
But to answer your question, I'd say you should try a GestureDetector. It's way easier to manage the events - Detecting Gestures

Is there a way to change the place where android menu appears

normally when the menu button is pressed , the menu appears from the center bottom of the screen. Is there a way to make it appear from sides.
On Android 3.0 and higher, items from the options menu are presented by the action bar which is standard way to provide access to menus and normally menus appears from top right corner. You should go through this once:
Menus Action Bar

Keyboard hides content in fragment, I need the frame layout to resize so bottom is just above the keyboard and now scrollable

I have a fragment in my app that has a scroll view for the signup and login pages. Right now there isn't enough content in the scroll view to actually make it scroll, however when the keyboard appears, it does cover up most of the content in the view. This causes a lot of issues especially on devices with smaller screens, it blocks a lot, and the view is NOT scrollable, so I have to close the keyboard to get to the rest of the inputs.
I need the bottom of the fragments frame layout to be pushed up to JUST above the top of the keyboard, so the keyboard won't actually hide any content, and still allow the scroll view to actually scroll to the rest of the content.
I have seen the usual fix to an issue similar to this, which would to change the AndroidManifest.xml to the following:
android:windowSoftInputMode="adjustResize"
but this will push up the entire page, which includes the footer view I have under and outside of the login and signup fragment layouts. It makes my scrollview smaller and allows for it to scroll, but I need the footer to stay hidden under the keyboard still.
I think a work around to this would be to have override onConfigurationChanged(); in MyActivity that will detect if the keyboard has appeared, and if it has, push the bottom of the framelayout to be JUST above the keyboard, thus making the scroll view smaller, and allowing us to actually scroll. I am not quite sure HOW to do this though.
Here is what it looks like with the keyboard up, blocking the content. This would be okay IF the scroll view was scrollable, allowing me to see the rest of the content, however it will not scroll and the only way to access the content under it is to close the keyboard first.
EDIT
I was able to use the answer below, editing the Android manifest for
android:windowSoftInputMode="adjustResize"
and the first method using the code below
final View activityRootView = findViewById(R.id.activityRoot);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView().getHeight() - activityRootView.getHeight();
if (heightDiff > 100) { // if more than 100 pixels, its probably a keyboard...
... do something here
}
}
});
I had it adjust my views so the footer would be pushed way down below, then resize the layout holding the fragment to extend down allowing it to be scrollable still.
Okay, here's how I solved it.
The basic idea is that you have to:
Detect whether or not a soft-keyboard is showing,
React. Based on the detected information (is-soft-keyboard-showing), resize your layout accordingly.
There are two ways of achieving this:
to give your activity's root view a known ID, say '#+id/activityRoot', hook a GlobalLayoutListener into the ViewTreeObserver, and from there calculate the size diff between your activity's view root and the window size:
Customize your top-level layout class into one which overrides onMeasure()
And I would like to credit the above answer to this SO Post: how-to-check-visibility-of-software-keyboard-in-android, which I have found earlier on this particular problem.

Android UX flow, next button on ActionBar

I am in a UX flow conundrum. In the ActionBar http://developer.android.com/design/patterns/actionbar.html, I am tasked to place a 'Next' button similar to that in iOS.
I am aware that Android has no equivalent button for that, is there a suggestion?
I would say it depends on your needs. Generally apps with a need for a Next button put it somewhere near the bottom-right of the screen.
I would personally be against putting it on the ActionBar as some devices handle it differently. Older devices might end up putting it behind the Menu button, and you'd have to be careful not to let it go into the overflow '...' menu as it may be too hidden-away in there (again, depending on your use case).
The other thing to remember is that putting it on the right of the Action Bar suggests that the button on the left of the Action Bar is a 'back' button, which is is not (It's an 'up' button).
I'm thinking more something like this:

Categories

Resources