📜  jetpack compose vertical viewpager (1)

📅  最后修改于: 2023-12-03 15:02:07.831000             🧑  作者: Mango

Jetpack Compose Vertical ViewPager

Jetpack Compose Vertical ViewPager is a library that allows you to create a vertical ViewPager using Jetpack Compose. With this library, you can easily create a vertical scrolling ViewPager that allows you to display multiple pages vertically.

Features
  • Vertical scrolling ViewPager.
  • Customizable number of pages to display at once.
  • Support for different page contents.
Usage

To use Jetpack Compose Vertical ViewPager, you first need to add the library to your project:

implementation 'com.pinguo.jetpack.compose:compose-vertical-viewpager:1.0.0'

Once you have added the library, you can create a vertical ViewPager by using the VerticalViewPager composable:

VerticalViewPager(
  pageCount = 3, // change this based on your needs
  pageContent = { index -> // create the content for each page
    // return your composable content here
  }
)

The pageCount parameter specifies the number of pages to display in the ViewPager. The pageContent parameter is a lambda that takes an index and returns the content for that page.

Customization

Jetpack Compose Vertical ViewPager allows you to customize the number of pages displayed at once by using the visiblePageCount parameter:

VerticalViewPager(
  pageCount = 3,
  visiblePageCount = 2, // only 2 pages will be visible at once
  pageContent = { index ->
    // return your composable content here
  }
)

You can also customize the height of the ViewPager by using the height parameter:

VerticalViewPager(
  pageCount = 3,
  visiblePageCount = 2,
  height = 500.dp, // set the height of the ViewPager to 500dp
  pageContent = { index ->
    // return your composable content here
  }
)
Conclusion

Jetpack Compose Vertical ViewPager is a useful library for creating a vertical scrolling ViewPager using Jetpack Compose. With this library, you can easily display multiple pages vertically in your app.