android - 设计 View 中底部导航的实时 View 不显示图标和菜单资源

标签 android xml android-studio android-layout

enter image description here [![在此处输入图像描述][2]][2]自 material io 1.5.0 起,在 Android Studio 的实时设计 View 中,底部导航 View 未显示其中的图标。,我在之前的项目中看到,在 material io 1.3.0 中,它可以在旧版本中运行,但不能在新版本中运行。

我只看到一个空的底部导航栏,上面什么也没有。我非常感谢您在这方面的帮助。

这里是 XML 代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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=".HomeActivity">

    <ImageView
        android:id="@+id/img_semirec_home"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:src="@drawable/ic_semirec_top"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        style="@style/Widget.MaterialComponents.BottomNavigationView.Colored"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:itemIconSize="20dp"
        app:menu="@menu/bottom_navigation_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>

Gradle :

plugins {
    id 'com.android.library'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 32

    defaultConfig {
        minSdk 26
        targetSdk 32

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        consumerProguardFiles "consumer-rules.pro"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    buildFeatures {
        viewBinding true
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation project (':resource')

    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.0'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.0'

}

最佳答案

这个问题是在使用新的material io 1.5.0库时出现的,在1.3.0上工作正常。

感谢 Niaj Mahmud 的帮助和支持

关于android - 设计 View 中底部导航的实时 View 不显示图标和菜单资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71356663/

相关文章:

xml - VS 2017 WebAPI 帮助页面 - 未提供文档

android - 将形状定位在 ImageView 上的确切位置

android - 方形按钮屏幕宽度和重量匹配

android - 以编程方式更改 ShapeDrawable 的描边宽度

javascript - Ajax XML 每 10 秒更新一次

android - 如果里面有另一个布局,背景会失去颜色

java - targetSdkVersion 30,不提示用户权限

android - 如何使Android应用程序只能安装在单个设备上?

android - Web 客户端库的云存储?

Android "first time"app用户教程