appbar_scrolling_view_behavior未在SwipeRefreshLayout数据绑定android解析

问题描述 投票:0回答:1

我尝试将应用程序:layout_behavior =“@ string / appbar_scrolling_view_behavior”添加到SwipeRefreshLayout,但我不知道为什么我没有在XML布局中解析,尽管它在运行代码后正常工作。这与数据绑定和MVVM有关吗?


<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">

    <data>

        <variable
            name="viewModel"
            type="ir.basamadazmanovin.heartrate.ui.main.home.HomeViewModel" />
    </data>

    <androidx.coordinatorlayout.widget.CoordinatorLayout

        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <androidx.swiperefreshlayout.widget.SwipeRefreshLayout
            app:layout_behavior="@string/appbar_scrolling_view_behavior"
            android:id="@+id/swipe_refresh_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:onRefreshListener="@{()-> viewModel.onRefresehing()}"
            app:refreshing="@{viewModel.isLoading}">


            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/fragment_home_recyclerView"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_marginStart="8dp"
                android:layout_marginTop="8dp"
                android:layout_marginEnd="8dp"
                app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
                app:spanCount="3" />

        </androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
        <com.google.android.material.appbar.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <androidx.appcompat.widget.Toolbar
                android:id="@+id/fragment_home_toolbar"
                style="@style/Toolbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:subtitleTextColor="@color/material_white"
                app:title="@string/app_name"
                app:titleTextAppearance="@style/Toolbar.TitleText"
                app:titleTextColor="@color/material_white" />
        </com.google.android.material.appbar.AppBarLayout>


    </androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>



implementation "com.google.android.material:material:1.0.0"

app:layout_behavior =“@ string / appbar_scrolling_view_behavior”为红色,IDE提到“未解析的类”@ string / appbar_scrolling_view_behavior'较少...(Ctrl + F1)检查信息:验证Android XML文件中的资源引用。“

android-databinding android-coordinatorlayout android-appbarlayout swiperefreshlayout android-mvvm
1个回答
2
投票

请改用:

            app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
© www.soinside.com 2019 - 2024. All rights reserved.