45,517 questions
Best practices
0
votes
1
replies
65
views
How to update NavigationDrawer selected item when navigating from a Fragment?
I would like to move navigation logic from MainActivity to MainFragment. However, when navigation happens, I also need to update the selected item in the NavigationDrawer, which is defined in ...
0
votes
1
answer
99
views
Android 15/16: returning from browser (deeplink) causes mixed DayNight theme in fragments (new fragments use system dark, old fragments stay light)
I have an Android app using AppCompat DayNight (Theme.MaterialComponents.DayNight.NoActionBar).
Goal
First run: app should follow OS theme (optional).
After user manually selects Light or Dark, the ...
0
votes
0
answers
64
views
Android "Fragment already added" despite smart fragment management
I thought my code works well in terms of fragments management because I have tested it manually for a long time. Besides Crashlytics also didn't notify me that users are having any problem with it for ...
0
votes
0
answers
71
views
CameraX/Camera2 API + PreviewView does not show the same field of view as equivalent zoom in default Camera App
I can't seem to figure out why utilizing a the Camera2 or CameraX API (backend) with a PreviewView element (frontend) as a viewfinder for the camera doesn't seem to show the same field of view as the ...
3
votes
1
answer
185
views
Fragment visibility issue: PlaylistsFragment shows blank screen after navigating back from child fragments
I have an audio player app, it's contain a PlaylistsFragment that contains 4 cards which navigate to other fragments (FavouritesFragment, RecentlyPlayedFragment, MostPlayedFragment, ...
3
votes
0
answers
138
views
Fragments, Predictive back animation customization
To implement Predictive Back feature in an app, that uses Fragments and Navigation Component, there are 2 options:
Option A: Use Transition API.
Just set animator animations directly into nav_graph ...
0
votes
1
answer
79
views
Android: How to change the FragmentManager Backstack when going back (insert a new fragment)?
I'm trying to add a view to the fragment stack, without any visible indication that it happened, so it appears when going back.
Forexample,
3 Fragments, A, B and C
A -> C
Then when going BACK from ...
1
vote
1
answer
207
views
Race condition with android fragment back stack changed listener?
I've got some code which looks like this in my main activity:
class MainActivity : AppCompatActivity() {
private val backStackListener = FragmentManager.OnBackStackChangedListener {
val ...
1
vote
0
answers
50
views
Android: App layout: floating bottom nav obscures fragment container
I'm trying to create this cool looking bottom nav where the fragment content "flows under it" as you scroll. Here's the screen, focus on the bottom: notice how you can see the content of the ...
2
votes
1
answer
83
views
Kotlin View Binding becomes Null outside liifecycle methods when returning from fragment
I have an app structured with one MainActivity and several fragments which are communicated with by some ImageButtons in this activity. In one fragment (UnreviewedFragment), I have a RecyclerView ...
0
votes
0
answers
70
views
Android BottomNavigationView overlaps list inside Fragment — how to add bottom spacing?
I’m having an issue with a Frame Layout inside a Fragment that also contains a Google Map and a BottomNavigationView.
Here’s my setup:
A BottomNavigationView is anchored to the bottom of the screen. ...
2
votes
1
answer
241
views
Jetpack Compose inside a Fragment: pass Fragment args directly to Composable or via ViewModel (SavedStateHandle)?
I’m migrating a Fragment-based app to Jetpack Compose incrementally. Some screens are still Fragments that host Compose with ComposeView. I recently changed a screen to pass a tabUid through Fragment ...
1
vote
1
answer
54
views
Cannot get rid of the unwanted color at the top of the screen (in the emulator) in Kotlin xml android
here is the code for the main page activity
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://...
-1
votes
1
answer
112
views
Edge to edge display [closed]
In a FragmentActivity, I try to set insets to correct the edge to edge appearance of my app. To do this, I copy the following code taken from Edge to edge display in my onCreate function :
...
0
votes
1
answer
41
views
Creating activity prevents spinner from spinning in Android
I have 2 activities in my app. When another one is called there is a spinner but it doesn't spin. I think it may be because the main thread is stuck.
I moved all background tasks to Dispatchers.IO, ...