Problem: I get a lint error and warning on styles that are working, when defining the orientation of a LinearLayout in a styles file, but not when defining the orientation directly on the element. Even though the property is picked up from the styles file.
I have a base style for all my activities, containing the following:
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="StandardActivity">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:orientation">vertical</item>
</style>
</resources>
In my layout, if I add this code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/StandardActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
...
</LinearLayout>
...
</LinearLayout>
On layout_width
I get a lint warning:
Use a 'layout_width' of '0dp' instead of 'fill_parent' for better performance
And on layout_height
I get a lint error:
Suspicious size: this will make the view invisible, probably intended for 'layout_width'
Everything is working as expecting and the layout takes the orientation
attribute set in StandardActivity
. However, the error and warning are only valid when the orientation is set to horizontal
. How can I get the lint in Android studio to understand that the orientation is set in the style-file?
If a explicitly add the orientation directly to the LinearLayout, the linting error and warning disappears.