【问题标题】:appbar_scrolling_view_behavior not resolved at SwipeRefreshLayout databinding androidappbar_scrolling_view_behavior 未在 SwipeRefreshLayout 数据绑定 android 解决
【发布时间】:2019-04-23 09:03:12
【问题描述】:

我尝试将 app: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 提及“Unresolved class '@string/appbar_scrolling_view_behavior' less... (Ctrl+F1) 检查信息:验证 Android XML 文件中的资源引用。”

【问题讨论】:

    标签: android-databinding android-coordinatorlayout android-appbarlayout swiperefreshlayout android-mvvm


    【解决方案1】:

    改用这个:

                app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
    

    【讨论】:

      猜你喜欢
      • 2019-09-23
      • 2016-01-14
      • 2020-09-29
      • 1970-01-01
      • 2019-11-20
      • 2020-01-18
      • 2021-07-23
      • 2019-09-11
      • 2020-12-26
      相关资源
      最近更新 更多