Appbar scrolling view behavior

Appbar scrolling view behavior

I’ve recently migrated my project to AndroidX. Now when I open specific page of the app that has code below, the app Crashes

Error in Logcat:

I think I must replace this behavior with it’s alternative in AndroidX. But what is that alternative code? I searched in But didn’t find AppBarLayout.

Thanks in advance.

1 Answer 1

I found the solution. The layout_behavior line must be replace with this:

I am looking to add scroll support to more than just a single, scrollable, child view of CoordinatorLayout in conjunction with an AppBarLayout and CollapsingToolbarLayout . When scrolling the RecyclerView or the AppBarLayout (condensed code below), the app bar and its contents successfully scroll and collapse. However, when attempting to initiate a scroll event on the LinearLayout above the RecyclerView , nothing happens because the LinearLayout does not know to scroll or collapse the view.

The goal is to have the LinearLayout act as a sticky header to the RecyclerView and footer to the AppBarLayout and receive the same scrolling behavior as the RecyclerView , similar to Spotify’s shuffle play/available offline header. In fact, it would be great if the appbar_scrolling_view_behavior layout_behavior could be applied to the LinearLayout similarly to the RecyclerView , but I imagine that the behavior is ignored on non-scrollable views. Is anyone aware of a workaround for this that does not require implementing the LinearLayout view as a row in the RecyclerView ?

Please refer to my below fragment .XML

in the above file line

displays error "Unresolved reference" in the editor, however it doesn’t generate any compilation error.

I have searched net and stackoverflow to find solution, it has mentioned that

Читайте также:  Разработать алгоритм вычисления гипотенузы прямоугольного треугольника по

must be included in the app gradle file. I have checked it, and both files are there in my app gradle file.

I am not able to resolve the error. Please help with this error. Further to above error, I am also facing other erratic behaviour in my app, which is as explained below:

When my above viewpager (Containing error) is initialized, I am instantiating four tabs and where four fragments are opened. My fragment file is as below:

Now, issue is along with first fragment, second fragment is also getting instantiated, and onCreate method is fired for both. However, after that even if, I click on tab-2 (Diagnosis), onCreate is not fired. However, for other two fragments (TAB-3 (Lab Tests) and TAB-4 (Prescribe)) every time onCreate is getting fired whenever those tabs are clicked.

I am failed to understand this erratic behaviour. Is this due to above Unresolved reference? I have tried to remove the line app:layout_behavior="@string/appbar_scrolling_view_behavior" , but above erratic behaviour remains as it is.

So, please help me in resolving above mentioned unresolved reference error and also above erratic behaviour of fragment initialization.

Ссылка на основную публикацию
Adblock detector