微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

@ string / appbar_scrolling_view_behavior自动完成未显示

如何解决@ string / appbar_scrolling_view_behavior自动完成未显示

所以我在youtube上遵循了本教程,但是我被困在11:08分钟,我不知道为什么我的activity.xml文件中没有显示我的@ string / appbar_scrolling_view_behavior

顺便说一下,这是youtube链接

https://www.youtube.com/watch?v=Qxf8yQVkeik&list=PLFRUC61dWGGFqUezKOGzI4403pAjM-jCv&index=14

请不要投票给我,如果您不喜欢我的问题,请在询问时给我关于这个问题和其他问题的建议,以提高我提出问题时的问题技巧。

这是我的困境:

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
    compileSdkVersion 30
    buildToolsversion "30.0.2"

    defaultConfig {
        applicationId "com.example.simple_fragment_kotlin"
        minSdkVersion 16
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'),'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation filetree(dir: 'libs',include: ['*.jar'])
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'androidx.core:core-ktx:1.3.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'




    // Android Support Library
    implementation 'com.google.android.material:material:1.0.0-alpha3'
}

这是我的android.xml文件

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayoutt 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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.AppBarLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
        >
        <com.google.android.material.tabs.TabLayout
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:tabTextColor="#000"
            app:tabSelectedTextColor="#fff"
            app:tabGravity="fill"
            app:tabMode="fixed"/>
    </com.google.android.material.appbar.AppBarLayout>

    <androidx.viewpager.widget.ViewPager
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:id="@+id/viewpager"
        app:layout_behavior="@string/appbar_scrolling_view_behavior"
        />

</androidx.coordinatorlayout.widget.CoordinatorLayoutt>

我用Kotlin编程语言使用androidx api 30

解决方法

在您的应用级别gradle中添加以下依赖项

'com.google.android.material:material:1.3.0-alpha02'

我希望它对您有用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。