-1

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

Gabriele Mariotti
  • 320,139
  • 94
  • 887
  • 841
skypore
  • 23
  • 5

2 Answers2

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)

enter image description here enter image description here

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