How to manage focus (and restore it) between TVLaz...
# compose-android
m
How to manage focus (and restore it) between TVLazyRow/LazyRow and focusable buttons in Android TV app?
I am developing an Android TV app using Jetpack Compose and D-pad navigation. My main screen UI looks like this: • A Column as the main container • The first item is a TVLazyRow or a normal LazyRow (which one should I use for TV apps and D-pad navigation?) ◦ Each card/item inside the row should be focusable and show a focus border when focused. ◦ Below the row, I have 2–3 focusable Texts or Buttons (with focus indication). My requirements: • D-pad navigation should work smoothly between all items (row cards and buttons/texts below). • When navigating from this screen to another and then returning, the previously focused item/component should automatically regain focus (focus restoration). My questions: 1. Should I use TVLazyRow or normal LazyRow for the best D-pad navigation experience on Android TV? 2. How do I save and restore focus when navigating back to this screen (so the same card or button is focused as before)? 3. What are the best practices or sample code for this focus management scenario in Jetpack Compose TV? Any advice, best practices, or code samples for this pattern on Android TV Compose would be appreciated!
m
If you're using compose , you can use the FocusRequester api with compose Modifiers for handling the focus, but, thats not easy task to do.
m
Thanks I try it but not work it difficult