Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Unknown attribute style on a fragment tag

Can someone please explain to me why I am getting this warning in Android Studio 1.1.0:

Unknown attribute style
Full warning: The inspection highlights unknown XML attributes in Android resource files and AndroidManifest.xml

Here is the code snippet:

<fragment
    android:id="@+id/frag_logo"
    tools:layout="@layout/fragment_logo"
    style="@style/FragmentLogo"/>

The warning occurs on the style attribute.

I am using gradle and android build tools 21.1.2

like image 628
langjacques Avatar asked Jun 19 '15 09:06

langjacques


2 Answers

The style attribute is supported for Views (and by inheritance ViewGroups), so fragments don't support it.

like image 54
Saif C Avatar answered Oct 27 '22 13:10

Saif C


For my configuration warning still exists but style works for fragments. Eventually fragments supply View on onCreateView() so style should work.

Android Studio 2.2.3
minSdkVersion 15
targetSdkVersion 25
gradle-2.14.1
like image 35
Ruslan Avatar answered Oct 27 '22 14:10

Ruslan