如何使用下拉列表制作 material 个筹码
how to make material chips with dropdown list
我正在尝试设计material个芯片,每个material是一个下拉列表
what I am trying to do
有什么方法可以激活这个
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" />
您可以使用类似的东西代替 Chip
组件:
<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>
与:
<style name="ShapeAppearanceOverlay.App.rounded50" parent="">
<item name="cornerSize">50%</item>
</style>
最后:
val items = listOf("Material", "Design", "Components", "Android")
val adapter = ArrayAdapter(this, R.layout.list_item, items)
(textField.editText as? AutoCompleteTextView)?.setAdapter(adapter)
我正在尝试设计material个芯片,每个material是一个下拉列表 what I am trying to do 有什么方法可以激活这个
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" />
您可以使用类似的东西代替 Chip
组件:
<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>
与:
<style name="ShapeAppearanceOverlay.App.rounded50" parent="">
<item name="cornerSize">50%</item>
</style>
最后:
val items = listOf("Material", "Design", "Components", "Android")
val adapter = ArrayAdapter(this, R.layout.list_item, items)
(textField.editText as? AutoCompleteTextView)?.setAdapter(adapter)