Android 加上「;重量“;插入芯片组以填充父级宽度的步骤
我在Android 加上「;重量“;插入芯片组以填充父级宽度的步骤,android,android-chips,Android,Android Chips,我在芯片组中有2个芯片。我需要它们填满整个屏幕,就像我们如何在线性布局中使用android:layou-weight一样 我试过这个: <com.google.android.material.chip.ChipGroup android:layout_width="match_parent" android:layout_height="wrap_content" app:singleSelection="true
芯片组中有2个芯片
。我需要它们填满整个屏幕,就像我们如何在线性布局中使用android:layou-weight
一样
我试过这个:
<com.google.android.material.chip.ChipGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:singleSelection="true"
app:selectionRequired="true"
>
<com.google.android.material.chip.Chip
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="@dimen/pill_button_height"
android:id="@+id/chip1"
style="@style/Widget.MaterialComponents.Chip.Choice"
app:shapeAppearanceOverlay="@style/Chip.LeftRounded"
android:text="Left"
/>
<com.google.android.material.chip.Chip
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="@dimen/pill_button_height"
android:id="@+id/chip2"
style="@style/Widget.MaterialComponents.Chip.Choice"
app:shapeAppearanceOverlay="@style/Chip.RightRounded"
android:text="Right"
/>
</com.google.android.material.chip.ChipGroup>
但是layout\u-weight
不起作用,因为宽度是0dp
,芯片就消失了。
如果有人知道如何解决这个问题,而不完全抛弃芯片组
并创建我自己的实现,这将非常有帮助
谢谢。A芯片组
不会从任何其他视图组继承,因此如果没有自定义实现或以编程方式计算宽度,这似乎是不可能的。是的,我也倾向于认为这是不可能的。SighIt完全取消芯片组
可能更容易,只需自己处理检查。我正是这么做的。使用芯片
,但不使用芯片组
。