android - 我似乎无法使导航抽屉工作:如何解决这个问题?
问题描述
我是 Android Studio 的新手,我正在尝试学习如何使用navigation drawer
. 但是,我不能让它出现在预览中。我尝试在创建新活动时自动执行此操作,但结果是一样的,这就是它的样子
这些是依赖项:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example."
minSdkVersion 21
targetSdkVersion 29
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 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.navigation:navigation-fragment:2.0.0'
implementation 'androidx.navigation:navigation-ui:2.0.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
implementation 'com.google.firebase:firebase-storage:16.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
解决方案
如果你想在编辑器预览中显示 - tools:openDrawer="start"
我发现了类似的问题: 从向导创建 DrawerLayout(带有 NavigationView)时 tools:openDrawer="start" 的目的是什么?
推荐阅读
- c - 分配偶数和奇数的数组
- c# - 如何在.net核心中终止/中止线程/任务
- java - MySQL:“SQL 语法错误”的来源
- python - 从 json 块中获取特定类型的所有标签
- powershell - 当`n和`r不起作用时如何在Powershell中删除隐藏的换行符
- python - 以列表为元素的 Python 字典及其比较
- spring-boot - 如何直接使用没有端口号的域开放网站?
- string - 从字符串文件创建 Scala Map 的最有效方法是什么?
- pyqt5 - QTableView -- 防止离开单元格和关闭委托编辑器
- git - Homebrew卸载问题/不确定我是否删除了重要文件