WheelPicker Android Library

repository·main·Indexed 25 days ago

https://github.com/devaige/wheelpicker

An Android library for highly customizable wheel-style pickers. It includes specialized widgets such as WheelDatePicker, WheelYearPicker, WheelMonthPicker, WheelDayPicker, and WheelAreaPicker for geographic selection (Provinces, Cities, and Areas). The library supports advanced visual effects including atmospheric, perspective, and mathematical curvature modeling, as well as Compose support.

Tokens
1.9K
Snippets
2
Records
24
Agent score
82%

What's inside WheelPicker

  1. Include WheelPicker in your project

    main

    Add the WheelPicker dependency to your build.gradle file.

    Important: Since version 1.2.2, internal dependencies are marked as compileOnly. You must manually add the following dependencies to your project to avoid runtime exceptions:

    // Core Dependencies
    implementation 'dev.aige.pub:WheelPicker:1.2.3'
    implementation("org.jetbrains.kotlin:kotlin-stdlib:<version>")
    implementation("androidx.appcompat:appcompat:<version>")
    implementation("com.google.code.gson:gson:<version>")
    
    // Compose Support (Optional)
    implementation(platform("androidx.compose:compose-bom:<version>"))
    implementation("androidx.compose.ui:ui")
    implementation("androidx.compose.runtime:runtime")
  2. Include WheelPicker via Maven

    main

    If you are using Maven, add the following dependency to your pom.xml:

    <dependency>
      <groupId>dev.aige.pub</groupId>
      <artifactId>WheelPicker</artifactId>
      <version>1.2.3</version>
      <type>pom</type>
    </dependency>
  3. Use WheelAreaPicker for geographic selection

    main

    The WheelAreaPicker is a specialized UI widget that provides a cascading selection interface for Provinces, Cities, and Areas. It automatically manages the relationship between these levels: selecting a province updates the available cities, and selecting a city updates the available areas.

    To use it, include it in your Android layout. It expects a data file named RegionJsonData.dat to be present in your project's assets folder to initialize the geographic hierarchy.

  4. Configure WheelYearPicker range and selection

    main

    The WheelYearPicker is a specialized WheelPicker for selecting years. You can control the range of available years and the currently selected year using the following properties:

    • yearStart: Sets the starting year of the picker. Setting this will reset the selectedYear to the currentYear.
    • yearEnd: Sets the ending year of the picker.
    • selectedYear: Sets the year currently selected in the picker.
    • setYearFrame(start: Int, end: Int): A method to set both the start and end years simultaneously. This also resets the selectedYear to the currentYear.
  5. Configure WheelMonthPicker selection

    main

    The WheelMonthPicker provides a selectedMonth property to control the selection.

    • Type: Int (Range: 1-12)
    • Behavior: Setting selectedMonth automatically updates the internal selectedItemPosition to match the month.

    Note: You cannot manually call setData() on a WheelMonthPicker; the month data (1-12) is immutable and managed internally.