In the process of updating to android gradle plugin 3.0, lint has suddenly started failing for views where layout_width and layout_height are defined in the style, rather than at the parent layout. One of the examples :
<Button
android:id="@+id/btn_positive"
style="@style/rounded_solid_button"
android:textAppearance="@style/TextAppearance.ProximaRegularFont"
android:textSize="@dimen/mini"
android:text="Ok"/>
and my 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 fails here stating :
The required layout_width and layout_height attributes are missing
Anybody else faced this issue?
Just checked, it's an issue in lint which has not been fixed in the stable release of AS :-/
https://issuetracker.google.com/issues/37138580
Clean and rebuild the project. It should work, but if it for some reason doesn't anymore you have to declare it in the view tag instead of in styles.xml
Alternatively, cleaning and invalidating the cache (assuming you use Android Studio/IntelliJ) should also do the trick
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With