SnackBar样式在使用材质组件后发生了更改



因为我想使用素材输入编辑文本,我不得不将我的风格更改为

<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">

但我的SnackBar风格已经改变了,在它之前(我使用的是AppCompat(,我的SnckBar是以不同的模式显示的,我的意思是,它从底部上升,过了一段时间就下降了,但现在它显示得像一个简单的吐司,它逐渐消失,如何在不更改视图样式的情况下使用材质构件?

在styles.xml BaseTheme:中添加以下行

<resources>
<style name="BaseTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge">
...
<item name="snackbarStyle">@style/Widget.MaterialComponents.Snackbar</item>
<item name="snackbarButtonStyle">@style/Widget.MaterialComponents.Button.TextButton.Snackbar</item>
<item name="snackbarTextViewStyle">@style/Widget.MaterialComponents.Snackbar.TextView</item>
</style>
</resources>

相关内容

最新更新