此问题不适用于android Button。请回答“材料”按钮。
我想要一个像下面的按钮
所以我使用了Button材质,我的代码就是这样
<style name="CustomShapeAppearance_left">
<item name="cornerSizeTopLeft">16dp</item>
<item name="cornerSizeBottomLeft">16dp</item>
</style>
<style name="CustomShapeAppearance_right">
<item name="cornerSizeTopRight">16dp</item>
<item name="cornerSizeBottomRight">16dp</item>
</style>
<com.google.android.material.button.MaterialButton
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Previous"
app:shapeAppearance="@style/CustomShapeAppearance_left" />
<com.google.android.material.button.MaterialButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Next"
app:shapeAppearance="@style/CustomShapeAppearance_right" />
我得到的结果是两个按钮之间的分隔线。 因此,我试图在ech按钮的右侧和左侧添加边框颜色,以至于无法获得结果。 但是如何针对材质按钮进行操作。
答案 0 :(得分:0)
只需在这两个按钮之间添加一个视图,例如-
<com.google.android.material.button.MaterialButton
android:id="@+id/previous"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Previous"
app:shapeAppearance="@style/CustomShapeAppearance_left" />
<View
android:layout_width="1dp"
android:layout_height="wrap_content"/>
<com.google.android.material.button.MaterialButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Next"
app:shapeAppearance="@style/CustomShapeAppearance_right" />