langjacques
langjacques

Reputation: 417

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

Upvotes: 8

Views: 2059

Answers (3)

Activity and Fragment supports android:theme. So please try this:

android:theme="@style/FragmentLogo"

Upvotes: 0

Ruslan
Ruslan

Reputation: 76

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

Upvotes: 1

Saif C
Saif C

Reputation: 421

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

Upvotes: 1

Related Questions