Android 如何将材质按钮形状外观与编辑文本形状外观分开?

Android 如何将材质按钮形状外观与编辑文本形状外观分开?,android,android-button,material-components-android,material-components,android-shapedrawable,Android,Android Button,Material Components Android,Material Components,Android Shapedrawable,在android中,您可以使用shapePearance.MaterialComponents.SmallComponent设置主题,因此如果我设置 <style name="Some.Theme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar"> ... <item name="shapeAppearanceSmallComponent">@style/ShapeAppearan

在android中,您可以使用
shapePearance.MaterialComponents.SmallComponent设置主题,因此如果我设置

<style name="Some.Theme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
    ...
    <item name="shapeAppearanceSmallComponent">@style/ShapeAppearance.MyShape.SmallComponent</item>
    ...
</style>
我可以把我的
材质按钮
做成圆形

我的问题是,这也会影响我所有的
Edittext
shapeAppearance
,这不是我想要的


是否可以为
按钮提供不同的
形状外观
,为
编辑文本
提供不同的
形状外观?

您可以通过覆盖组件的样式并定义自定义的
形状外观覆盖来更改组件的形状

例如,对于MaterialButton,您可以在应用程序主题中使用
materialButtonStyle
属性:

<style name="Some.Theme" parent="@style/Theme.MaterialComponents.DayNight.NoActionBar">
   <item name="materialButtonStyle">@style/MyApp.Button</item>
</style>

@样式/MyApp.Button
其中:

<style name="MyApp.Button" parent="@style/Widget.MaterialComponents.Button">
   <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.MyApp.MaterialButton</item>
</style>

<style name="ShapeAppearanceOverlay.MyApp.MaterialButton" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">@dimen/...</item>
</style>

@样式/形状PearanceOverlay.MyApp.MaterialButton
圆的
@迪蒙/。。。
<style name="MyApp.Button" parent="@style/Widget.MaterialComponents.Button">
   <item name="shapeAppearanceOverlay">@style/ShapeAppearanceOverlay.MyApp.MaterialButton</item>
</style>

<style name="ShapeAppearanceOverlay.MyApp.MaterialButton" parent="">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">@dimen/...</item>
</style>