Backpress in Jetpack Compose resets the status of the previous screen - android

I am currently migrating my old Android app (based on xml-views) to Jetpack Compose. I use a Single Activity for all my composables (views). I use a NavController to navigate. There is something that is not clear to me:
In classic xml views, when you scroll or enter something in a text field on a particular screen for example, and you open a new Activity, and you press the backbutton, the scroll position and the text entry on the previous screen is still visible. In Compose, the screen is reset to its starting position when pressing backbutton. For some screens this is not a problem, but for others it is. Can someone help me how to solve this in Compose?

Related

ModalBottomSheetLayout reappearance on navigation Jetpack Compose

I have some items in a modal sheet layout and when I press an Item, I navigate to another screen. However, when I press back button in the detail screen, the modal sheet reappears with a flashing behavior. I think this is because of recomposition but is there a way to prevent the recomposition without using a box and hiding-revealing the other screen? Any help is appreciated.
Maybe you need to pop the bottom sheet from the backstack?
When navigating to your detail screen from the bottom sheet, get the instance of the BottomSheetNavigator you used to create the ModalBottomSheetLayout and do:
bottomSheetNavigator.popBackStack(backstackEntry, true)
You get the backstackEntry from the lambda when calling bottomSheet(route)

Button Press in jetpack compose showing multiple recomposition

Hello the code is very simple on pressing a button i am changing the mutableState value.But i found the on button press recomposition is happening multiple time.
So is this some bug or for button the property is a bit different

Android | How to hide BottomNavigation even if windowSoftInputMode is set to 'adjustResize'?

I have an activity with BottomNavigation. If the user needs to click on the submit button soft keyboard hides it. Then he again needs to press the back button to see the submit button. In this case, I used windowSoftInputMode='adjustResize' so that the screen gets resized automatically and the user can scroll up and click on the submit button.
But, I have BottomNavigation too, windowSoftInputMode='adjustResize' makes BottomNavigation float above the soft keyboard. Can anyone suggest a better solution? Any help will be appreciated. Thanks
Thats tricky issue... You have two options in here:
Keep 'adjustResize' and hide BottomNavigation view when keyboard pops up (e.g. simply setVisiblity?)
Change to e.g. 'adjustPan' (or any other) preventing keyboard resizing app and add bottom padding with height of keyboard for whole content container. BottomNavigation will stay hidden under keyboard, but padding will allow scrolling to Submit button
In both cases you need to detect open/close keyboard, in second case you will also need keyboard height measuring. IN HERE and HERE you have big SO topics about this case, check out answers and comments, and pick proper resolution for your purposes

Jetpack navigation force show back arrow

I would like to know if it is possible to force a back arrow to show. Here's my use case:
main module with a list
detail screen (dynamic feature module)
Now in this details screen, I would like to know if it is possible to force a back arrow to show (and actually poping the activity out).
The details module has
Activity with...
X amount of fragments (view, create, edit)
I would like all of these to be considered as top-level but unlike most q&a here on SO to always show the back button.
Thanks for your time!

Application level floating views with navigation in Android

I have to show a floating button that will be added in WindowManager so it remain on the top of all Activities. (I have done this part using https://github.com/marshallino16/FloatingView)
When that button is tapped I have to open screen and show detail view and navigate between other views. To achieve this thing I can do following things either adding
1 - PopUpWindow
2 - Dialog
But I cannot provide navigation using either of them. So my questions is.
What is the best way to add multiple views and providing navigation between them while keeping everything above the application that is running it.
How can we add Activity so that it won't pause user application?
You should open Activity and implement all navigation inside it.
Android may pause activities behind, so make your Activity only for part of the screen.
Inside Activity hide floating button and show it again on exit.

Categories

Resources