Thi*_*aux 8 android themes material-design android-cardview
我正在尝试在新的Google Material组件上测试我的技能.但是现在我遇到了一个问题MaterialCardView
建设过程告诉我
The style on this component requires your app theme to be Theme.AppCompat
[..]
at com.google.android.material.card.MaterialCardView.<init>
Run Code Online (Sandbox Code Playgroud)
有了这个线索,我添加
style="@style/Theme.AppCompat"&android:theme="@style/Theme.AppCompat"到MaterialCardView,也对我在清单活动.
我也尝试将我的Acitivity更改为AppCompatActivity但没有任何成功.
我也尝试设置由material.io文档讲述的样式但没有成功!
你有一些线索吗?
谢谢
根据 Material Components 1.2.1 你需要这样做:
implementation 'com.google.android.material:material:1.2.1'compileSdkVersion 30AppCompatActivity(或使用AppCompatDelegate)来源:https : //github.com/material-components/material-components-android/blob/master/docs/getting-started.md
最简单的入门方法是将当前主题扩展Theme.MaterialComponents.*.Bridge而不是Theme.AppCompat.*.
此外,您需要覆盖主题中的以下属性,否则卡片颜色将被破坏:
<style name="AppTheme" parent="Theme.MaterialComponents.Light.DarkActionBar.Bridge">
<item name="elevationOverlayEnabled">false</item>
</style>
Run Code Online (Sandbox Code Playgroud)
不要android:theme="@style/Theme.MaterialComponents"在卡上设置。您将丢失卡片内每个小部件上主题的颜色信息(主要、次要、重音等)。
不要style="@style/Theme.MaterialComponents在卡上设置。不要混合主题和风格。
| 归档时间: |
|
| 查看次数: |
600 次 |
| 最近记录: |