Last active
April 21, 2021 14:56
-
-
Save milhauscz/a19464915f462837ebc24582f9404005 to your computer and use it in GitHub Desktop.
Example of an XML layout using MaterialSpinner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<layout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto"> | |
<data> | |
<import type="com.google.android.material.textfield.TextInputLayout" /> | |
<variable | |
name="viewModel" | |
type="com.example.SpinnerViewModel" /> | |
</data> | |
<FrameLayout | |
android:id="@+id/wrapper" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<com.google.android.material.textfield.TextInputLayout | |
android:id="@+id/input_layout" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:hint="@string/selection_hint" | |
app:startIconDrawable="@drawable/selection_icon" | |
app:boxBackgroundMode="outline" | |
app:endIconMode="@{viewModel.items == null || viewModel.items.size() != 0 ? TextInputLayout.END_ICON_DROPDOWN_MENU : TextInputLayout.END_ICON_NONE}"> | |
<com.example.MaterialSpinner | |
android:id="@+id/items" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
app:items="@{viewModel.items}" | |
app:selectedPosition="@={viewModel.selectedItemPosition}" | |
app:emptyText="@string/selection_no_item_text" /> | |
</com.google.android.material.textfield.TextInputLayout> | |
</FrameLayout> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment