我使用的是Android Studio 1.5.1,而我的素材设计却出现渲染错误。这是styles.xml
页面,没有材料修改:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
这是使用材料编辑的代码。
<!-- Base application theme. -->
<style name="AppTheme" parent="android:Theme.Material.Light">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
出于某种原因,它给出了
&#34;注意:一个或多个布局缺少layout_width或 layout_height属性。大多数布局都需要这些。&#34;等 预览。在我的Nexus 6P上运行也会出现同样的问题。我&#39;米 使用Android 6.0.1。它也找不到&#34; toolbarStyle&#34;。我是 初学者,有人可以帮忙吗?
编辑:我的&#34;自动添加缺失的属性&#34;链接不起作用。
答案 0 :(得分:1)
如果使用Theme.AppCompat.Light.DarkActionBar
已使用 Material Design ,则概念之间会有一些误解。
来自How to set up your Android app project to use Material Design with AppCompat
AppCompat v21。+的Theme.AppCompat扩展了Theme.Base.AppCompat 扩展了Theme.Platform.AppCompat,它扩展了android:Theme.Material 21个以上的设备(即Android 5.0 Lollipop),所以你只需要扩展 如果您正在使用AppCompat,则Theme.AppCompat使用Material主题 v21(或以上)库。
希望这有帮助!