I try to make an app using one activity multiple fragments pattern. I handle navigation with Navigation architecture component using a bottom navigation view. In one of the fragment I have a Recyclerview which displays a list of custom cards. On item click it navigates to another fragment where I need to hide the bottom navigation view.
The problem appears when I navigate back and set the bottom navigation view visible again. The bar seems to appear in two steps giving the feeling of lag. (first time appears just 60% of the bottom navigation view).
The behavior seems to be related with the status bar. When I change the theme to full screen or I set windowTranslucentStatus=true, everything behaves okay. In addition, first time the nav bar seems to be with exactly 24dp smaller, that is the dimension of status bar.
Have you any idea what can I do?
PS. I'm new on stackoverflow and this is my first question. I'm glad to join this wonderful community.
Delay is one way to go, but I wouldn't suggest that.
I am assuming that the your navigation view is rendered before the entire activity is rendered, which is causing it to be rendered again after the UI is rendered. Why don't you try setting the visibility after the UI is rendered, like here
Related
Please, help me to understand how to do it right.
I have an app, which represent a screen with bottom bar with 4 tabs (1st layer). From this tabs we can enter other screens (2nd layer) without bottom bar. This organized very simple, Scaffold with bottom bar and navigation host inside it. To open screens above 1st layer without navigation bar I searched and found that I can just hide bottom bar and then open the screen above.
This is good, but on slow devices an ugly animation happen when 1)bottom bar is going down (user see the old screen without bottom bar) and 2) new screen appears.
This is not pleasant, but.. ok.
The second thing that I cannot stand is when in a 1-st layer screen I have a ModalBottomSheetLayout. When it hidden - it hides right behind bottom navigation bar and when I am going to new screen bottom navigation animated down and... here you are - the ModalBottomSheetLayout, and only then the second screen come to the place.
I wonder, may be I understand everything wrong and the new screens shouldn't be organized like this? How to set up navigation and scene like before compose we have a main fragment with bottom nav bar and open fragments on the top?
The example of the code I am talking about can be found for example in app nowinandroid, I think this is very common case.. As I see they also just hide bottom bar when needed..
#Composable fun NiaApp...
So i have an app in compose that has startDestination set as a screen with scaffold with bottom nav bar having 3 items and top app bar, i am able to navigate through the 3 bottom navigation tabs. But suppose i want to click on a card in one of the bottom tab screen which should open a details screen without the bottom bar and app bar (Since Navhost is inside the scaffold, bottom and top bars show up on details screen too), what is the right way to do that? Currently i have tried the following ways:-
1. Starting the details screen in a new activity.
2. Using currentDestination route as state to conditionally hide bottom and app bar for details screen route.
Both work but, the problem with first approach is that, it isn't recommended to use multiple activity with jetpack navigation and rather we should stick to a single activity, it also further breaks the navigation if in case i want to move from details to another screen. The problem with second approach is that hiding and showing bottom/top bars create very bad transition between the screens and app doesn't feel smooth.
Hence, i am looking for an appropriate way to handle this as per the guidelines, although i couldn't find any info on this.
Update
I went with showing/hiding the bottom and app bar based on routes, turns out that bad and laggy animation i was facing was because i was running a debug app, with a release app with minifyEnabled true (R8) ,the transitions are very smooth and natural, as i wanted them.
Also it turns out, as per Google's official compose sample app JetSnack , this is the appropriate way of achieving navigation from a bottombar screen to a non-bottombar screen. Thanks to #vitidev for pointing it out in the comments.
You can use a nested Navigation Graph:
one principal graph according to your BottomBar
one nested graph inside each screen you want to go further
https://developer.android.com/jetpack/compose/navigation#nested-nav
I have a TabbedPage with four tabs in Xamarin.Forms. The four tab pages each inherit from a common ContentPage with an AbsoluteLayout. When I push to this TabbedPage on Android, the new navigation bar momentarily appears about one-third of the way down the screen then rapidly animates to its proper position at the top of the screen, before other screen elements are displayed. It's very distracting, and even happens (without any text) if I do not set a title at all. Does not happen on iPhone.
How can I prevent this animation?
Edit: Here is a video showing the problem at 0:02, 0:24 and 0:40 : https://drive.google.com/drive/folders/1rHxS_rcVEr8sPC0yujcZf34XvLJ7yJ2K?usp=sharing
Well, the navbar animates from bottom to top of the screen and it stopped midway because I was doing too much on the UI thread in OnAppearing.
Adding a 200ms delay in OnAppearing was one way to avoid it.
I'm using a GridView that fills the whole of my main activity. To make it look nicer I'm using a transparent action bar. I'm using these values on my grid view so that the content doesn't start in the action bar but still scrolls through it:
android:paddingTop="?android:attr/actionBarSize"
android:clipToPadding="false"
The only problem is once the bottom of the row enters the action bar it disappears. I'm assuming because Android thinks it is no longer visible so it's safe to remove.
I'd like a way for it to not disappear, even past the status bar as I'll probably make that transparent on KitKat too. Either a different approach or a simple solution would be great.
Turns out this was a problem with the TwoWayGridView library I was using (https://github.com/jess-anders/two-way-gridview). Switched back to a normal GridView and it works fine.
I want my ActionBar to act like it does in the stock/default Android browser:
It visible at the top of the page, but as the user scrolls down, the bar scrolls out of view, how ever if you scroll the page upward towards the top, the bar comes in to view again, but will hide after some time out, when it does this, it does not affect the underlying view.
I've tried implementing auto-hiding using timers but when the ActionBar hides, it moves up the scrollable view underneath so it looks as is my whole page shifts up instead of the ActionBar floating over the top of the view.
You are looking for the action bar overlay mode in combination with the Quick Return pattern. That is the feature, where a view becomes visible on top again when the user scrolls up a little. See this excellent blog post describing this pattern. Don't miss the example implementation by Roman Nurik from Google.
Enable the overlay mode by requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY) before setContentView() or by setting the theme attribute android:windowActionBarOverlay to true.
Did you try the overlay mode on the ActionBar, getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY)?
Then add a marginTop to your main layout.