所以我在youtube上学习了这个教程,但是我被困在了11点08分,我不知道为什么我的@string/appbar_scrolling_view_behavior没有显示在我的activity.xml文件中。
顺便说一句,这是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>我使用androidx api 30,用kotlin编程语言。
发布于 2020-10-07 08:38:27
在应用程序级梯度中添加下面的依赖项
'com.google.android.material:material:1.3.0-alpha02'我希望它能对你有用。
https://stackoverflow.com/questions/64239562
复制相似问题