升级到 gradle 插件 3.0 时出现 Lint 错误:缺少 layout_width 或 layout_height 属性
Lint error when upgrading to gradle plugin 3.0 : Missing layout_width or layout_height attributes
在更新到 android gradle 插件 3.0 的过程中,对于样式中定义了 layout_width
和 layout_height
的视图,lint 突然开始失败,而是比父布局。例子之一:
<Button
android:id="@+id/btn_positive"
style="@style/rounded_solid_button"
android:textAppearance="@style/TextAppearance.ProximaRegularFont"
android:textSize="@dimen/mini"
android:text="Ok"/>
和我的 styles.xml
:
<style name="rounded_solid_button">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/button_text_color</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
<item name="android:background">@drawable/rounded_solid_button</item>
<item name="android:layout_marginTop">20dp</item>
<item name="android:textSize">@dimen/title</item>
<item name="android:singleLine">true</item>
</style>
Lint 在这里失败说明:
The required layout_width and layout_height attributes are missing
还有其他人遇到过这个问题吗?
清理并重建项目。 It should work,但如果由于某种原因它不再存在,您必须在视图标记中而不是在 styles.xml
中声明它
或者,清除缓存并使其失效(假设您使用 Android Studio/IntelliJ)也应该可以解决问题
刚刚检查过,这是 lint 中的一个问题,尚未在 AS 的稳定版本中修复:-/
在更新到 android gradle 插件 3.0 的过程中,对于样式中定义了 layout_width
和 layout_height
的视图,lint 突然开始失败,而是比父布局。例子之一:
<Button
android:id="@+id/btn_positive"
style="@style/rounded_solid_button"
android:textAppearance="@style/TextAppearance.ProximaRegularFont"
android:textSize="@dimen/mini"
android:text="Ok"/>
和我的 styles.xml
:
<style name="rounded_solid_button">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_gravity">center_horizontal</item>
<item name="android:gravity">center</item>
<item name="android:textColor">@color/button_text_color</item>
<item name="android:textStyle">normal</item>
<item name="android:textAllCaps">false</item>
<item name="android:background">@drawable/rounded_solid_button</item>
<item name="android:layout_marginTop">20dp</item>
<item name="android:textSize">@dimen/title</item>
<item name="android:singleLine">true</item>
</style>
Lint 在这里失败说明:
The required layout_width and layout_height attributes are missing
还有其他人遇到过这个问题吗?
清理并重建项目。 It should work,但如果由于某种原因它不再存在,您必须在视图标记中而不是在 styles.xml
中声明它或者,清除缓存并使其失效(假设您使用 Android Studio/IntelliJ)也应该可以解决问题
刚刚检查过,这是 lint 中的一个问题,尚未在 AS 的稳定版本中修复:-/