A library that provides a hint to a spinner. Contains a set of attributes for customising font size, arrows, divider, item layout, item background, cell gravity, popup alpha and icon animation.
Add below lines to root's build.gradle
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Grab via Gradle
implementation 'com.github.Mobile-Innowise-Group:HintedSpinner:{latest version}'
Method | What it does |
---|---|
setItems | set List of String values |
setSelection | select a specific list item |
setHint | set your hint |
setHintTextSize | set size of your hint |
setHintTextColor | set color of your hint |
setPopupBackground | set background of the open spinner |
showDivider | show (or hide) divider |
setDividerColor | set color of your divider |
setArrowDrawable | set your custom arrow picture |
setArrowTint | set tint for your arrow |
setOnSelectItemAction | make something when item selected |
setItemsWithIcons | make List of String values with icons |
setCellGravity | set element gravity in the cell |
setIconAnimation | show arrow animation for collapsed/expanded state |
setPopupAlpha | set alpha for popup background |
At start set list of items:
<resources>
<string-array name="text">
<item>Standard Text</item>
<item>Meeeeeeeeeeeeeeedium Text</item>
<item>Very looooooooooooooooooooooooooooooooooooooooooong</item>
</string-array>
</resources>
After you get simple spinner:
<com.innowisegroup.hintedspinner.HintedSpinner
android:id="@+id/hintedSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="Custom hint"
app:items="@array/text" />
Collapsed spinner:
Expanded spinner:
If you want, you can customize the attributes
<com.innowisegroup.hintedspinner.HintedSpinner
android:id="@+id/hintedSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
app:hintTextSize="24sp"
app:hintTextColor="@color/red"
app:hint="Custom hint"
app:withDivider="true"
app:dividerColor="@color/dark_green"
app:arrowDrawable="@drawable/example_arrow_4"
app:arrowTint="@color/colorAccent"
app:popupBackground="@color/light_blue"
app:items="@array/text" />
Collapsed spinner:
Expanded spinner:
Also you can set the items with icons
hintedSpinner.setItemsWithIcons(
listOf(
SpinnerIconItem(
"Standard Text",
R.drawable.example_arrow_1
),
SpinnerIconItem(
"Meeeeeeeeeeeeeeedium Text",
R.drawable.example_arrow_2
),
SpinnerIconItem(
"Very looooooooooooooooooooooooooooooooooooooooooong",
R.drawable.example_arrow_3
),
SpinnerIconItem(
"Hello Bob",
R.drawable.example_arrow_4
),
SpinnerIconItem(
"Hello Rachit",
R.drawable.example_arrow_5
)
)
)
<com.innowisegroup.hintedspinner.HintedSpinner
android:id="@+id/hintedSpinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
app:hintTextSize="14sp"
app:popupAlpha="228"
app:iconAnimation="true"
app:arrowDrawable="@drawable/example_arrow_4"
app:popupBackground="@color/colorPrimaryDark" />
Collapsed spinner:
Expanded spinner:
MIT License
Copyright (c) 2019 Innowise Group
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.