Question

[Solved] Unresolved class ‘@string/appbar_scrolling_view_behavior’

After i updated Android Studio i get this error in my xml for my viewpager.
Weird thing is it works fine and the project builds without any problems.

What is the reason that ‘@string/appbar_scrolling_view_behavior’ is an
Unresolved class?

 <android.support.v4.view.ViewPager
     android:id="@+id/viewPager"
     android:layout_width="match_parent"
     android:layout_height="match_parent"           
     app:layout_behavior="@string/appbar_scrolling_view_behavior">
 </android.support.v4.view.ViewPager>

My viewpager is inside a CoordinatorLayout.

Enquirer: Vince VD

||

Solution #1:

Same here. Looks like bug in IDE, not in app.

New project (default Tabs) in Android Studio 3.4 shows a warning:

Unresolved class ‘@string/appbar_scrolling_view_behavior’
Inspection info: Validates resource references inside Android XML files.

Not resolved by invalidating cache, clean build, project sync.

Code:

<android.support.v4.view.ViewPager
    android:id="@+id/view_pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
/>

When i removed the last line the tabs were not working correctly:

  • fragment in second tab was not shown
  • scroll top position is wrong, goed under top bar

So the IDE cant find it, but the app is definitely using the string/class.

Respondent: Barry Staes

Solution #2:

Those who use or migrated to AndroidX, you can use the following fix to remove the error. This also works in Android Studio 3.4

app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
Respondent: Midhun Murali

Solution #3:

I came across the same problem multiple times.

I always use tools:layout_behavior instead of app:layout_behavior

Respondent: Ilias

Solution #4:

As Barry Staes pointed out, it looks like a bug in the IDE. However, if you’re using the design library, this syntax should make the error go away:

app:layout_behavior="android.support.design.widget.AppBarLayout$ScrollingViewBehavior"

Solution #5:

Go to app level build.gradle and add :

def support_version="28.0.0"
implementation "com.android.support:design:$support_version"

if not working, modify only the support_version

Respondent: StrouStrup

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy