Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 使用材质组件后,SnackBar样式已更改_Kotlin_Styles_Material Components Android - Fatal编程技术网

Kotlin 使用材质组件后,SnackBar样式已更改

Kotlin 使用材质组件后,SnackBar样式已更改,kotlin,styles,material-components-android,Kotlin,Styles,Material Components Android,因为我想使用材质输入编辑文本,所以我必须将样式更改为 <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar.Bridge"> 但是我的SnackBar风格已经改变了,在它(我使用AppCompat)之前,我的SnackBar是以不同的模式显示的,我的意思是,它从底部出现,过了一段时间它就消失了,但现在它像一个简单的烤面包片一样显示,它淡入然后淡出, 如何在不更改视图样式的情况下使用材质

因为我想使用材质输入编辑文本,所以我必须将样式更改为

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

但是我的SnackBar风格已经改变了,在它(我使用AppCompat)之前,我的SnackBar是以不同的模式显示的,我的意思是,它从底部出现,过了一段时间它就消失了,但现在它像一个简单的烤面包片一样显示,它淡入然后淡出,
如何在不更改视图样式的情况下使用材质组件?

在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>

...
@style/Widget.MaterialComponents.Snackbar
@style/Widget.MaterialComponents.Button.TextButton.Snackbar
@style/Widget.MaterialComponents.Snackbar.TextView

发布屏幕截图