[当我将ChipGroup和Chips添加到XML时,它首先给我带来了导致活动崩溃的渲染问题。我通过将gradle.app中的支持库版本从实现“ com.google.android.material:material:1.2.0-alpha05”更改为alpha02并将AppTheme更改为“ Theme.MaterialComponents.Light.DarkActionBar”来解决了此问题。] >
**现在的问题是,在androidStudio的设计部分中,芯片的形状为默认形状,即为圆形,但在仿真器和实际设备上为菱形。我尝试了app:chipCornerRadius =“ 5dp”属性,但没有得到期望的结果。
如何将芯片的形状更改为四舍五入/默认值?**
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.our_team.OurTeamActivity">
<HorizontalScrollView
android:id="@+id/horizontalScrollView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:scrollbars="none"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.chip.ChipGroup
android:id="@+id/chipGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="36dp"
app:singleLine="true"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.google.android.material.chip.Chip
android:id="@+id/chip4"
style="@style/Widget.MaterialComponents.Chip.Choice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:chipCornerRadius="5dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:text="One Choice"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
<com.google.android.material.chip.Chip
android:id="@+id/chip5"
style="@style/Widget.MaterialComponents.Chip.Action"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:text="Two Action"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
<com.google.android.material.chip.Chip
android:id="@+id/chip6"
style="@style/Widget.MaterialComponents.Chip.Entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:text="Three Entry"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
<com.google.android.material.chip.Chip
android:id="@+id/chip7"
style="@style/Widget.MaterialComponents.Chip.Filter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:text="Four Filter"
android:textAppearance="@style/TextAppearance.AppCompat.Caption" />
</com.google.android.material.chip.ChipGroup>
</HorizontalScrollView>
[当我将ChipGroup和Chips添加到XML时,它首先给我带来了导致活动崩溃的渲染问题。我通过更改实现'com ....
在Chip
中,拐角的默认值由shapeAppearanceOverlay