简体   繁体   中英

Pagination in Wear OS

Good Morning, I'm developing a new Wear OS application. The thing is, I can't find anywhere how to make a good pagination .
I would like to change activity on swipe (no matter if it's vertical or horizontal) but can't find anywhere how to do it...
Maybe I should not navigate in my app like that ? Can you help me if you have any answer on how to do it ?
thanks ! (for some reasons I can't say hello on my post ?)

You can use HorizontalPager or VerticalPager from Accompanist.

https://google.github.io/accompanist/pager/

                HorizontalPager(
                    modifier = Modifier.fillMaxSize(),
                    count = 10,
                    state = state
                ) { page ->
                        Box(
                            modifier = Modifier.fillMaxSize(),
                            contentAlignment = Alignment.Center
                        ) {
                            Text(text = "Screen $page")
                        }
                    }
                

An example https://github.com/google/horologist/blob/e2741cef87774b18d58bb1b0f78bd5b60901f20d/sample/src/main/java/com/google/android/horologist/scratch/ScratchActivity.kt#L79

If you want something more custom, then it's probably a serious investment in a component. Especially if it needs to work with the system Swipe to Dismiss.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM