I am trying to design material chips, each material is a dropdown list what I am trying to do is there any way to active this
Asked
Active
Viewed 930 times
-1

Gabriele Mariotti
- 320,139
- 94
- 887
- 841

skypore
- 23
- 5
-
Can u add some more inputs. From your question i understand you want to create a dropdown which has rounded borders, right? – Neel Dsouza May 30 '21 at 17:14
-
@skypore You can add a dropdown arrow using `app:closeIcon` and then programmatically inflate a popup menu. – Piyush Satija May 30 '21 at 17:36
-
@NeelDsouza ex. listof("car1","car1","car1") – skypore May 30 '21 at 17:48
-
Welcome to stackoverflow, take a look at [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) – Yeheshuah May 31 '21 at 01:59
2 Answers
0
chip.setOnCloseIconClickListener {
val menu = PopupMenu(requireContext(), it)
menu.getMenu().add("AGIL")
menu.getMenu().add("AGILarasan")
menu.getMenu().add("Arasan")
menu.show()
}
<com.google.android.material.chip.Chip
android:id="@+id/chip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_marginStart="4dp"
android:layout_marginTop="16dp"
android:text="@string/email_address"
android:textColor="@color/greyish_brown"
app:checkedIconEnabled="false"
app:chipBackgroundColor="@color/white"
app:chipStrokeColor="@color/light_grey_level_1"
app:chipStrokeWidth="1dp"
app:closeIcon="@drawable/ic_arrow_dropdown"
app:closeIconEnabled="true"
app:closeIconSize="10dp"
app:closeIconTint="@color/greyish_brown"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

skypore
- 23
- 5
0
Instead of a Chip
component you can use something like:
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/textField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox.ExposedDropdownMenu"
app:shapeAppearanceOverlay="@style/ShapeAppearanceOverlay.App.rounded50"
>
<AutoCompleteTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</com.google.android.material.textfield.TextInputLayout>
with:
<style name="ShapeAppearanceOverlay.App.rounded50" parent="">
<item name="cornerSize">50%</item>
</style>
Finally:
val items = listOf("Material", "Design", "Components", "Android")
val adapter = ArrayAdapter(this, R.layout.list_item, items)
(textField.editText as? AutoCompleteTextView)?.setAdapter(adapter)

Gabriele Mariotti
- 320,139
- 94
- 887
- 841