Search code examples
androidlistandroid-layoutdropdown

Two separate vertical list scrolling in dropdown


I want the design layout in android like same as shared here in image. there are two separate vertical scrolling. Any help will be appreciated.

Click to see the image here


Solution

  • In your layout put a spinner, for example

    <Spinner
        android:id="@+id/spinner"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:spinnerMode="dropdown"/>
    

    Then, create an adapter for your spinner See here 'how to'

    for 2 scroll list, you can do it like this in your adapter item layout

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:orientation="horizontal">
    
        <NumberPicker
            android:id="@+id/picker_month"
            android:layout_width="wrap_content"
            android:theme="@style/NumberPickerText"
            android:layout_height="wrap_content"
            android:layout_marginEnd="20dp"
            android:layout_marginRight="20dp">
    
        </NumberPicker>
    
        <NumberPicker
            android:id="@+id/picker_year"
            android:theme="@style/NumberPickerText"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content">
    
        </NumberPicker>
    
    </LinearLayout>