【问题标题】:Navigation drawer showing pink in oreo在 oreo 中显示粉红色的导航抽屉
【发布时间】:2018-11-13 06:14:39
【问题描述】:

这是我的 gradle 文件

在 oreo 中我没有得到正确的输出。

这是我在奥利奥中得到的输出。

我尝试升级 compileSdkVersion,但得到一个错误,所有库必须使用相同的版本。 请告诉我如何解决这个问题。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion '26.0.2'

    defaultConfig {
        applicationId "com.rayvatapps.inspiquo"
        minSdkVersion 21
        targetSdkVersion 22
        versionCode 12
        versionName "3.4"
    }
    buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

repositories {
    jcenter()
}

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:22.2.0'
    implementation 'com.android.support:appcompat-v7:22.2.0'
    implementation 'com.android.support:support-v4:22.2.0'
    //cardview
    implementation 'com.android.support:cardview-v7:22.2.0'
    //recyclerview
    implementation 'com.android.support:recyclerview-v7:22.2.0'
    //glide
    implementation 'com.github.bumptech.glide:glide:3.6.0'
    implementation 'de.hdodenhof:circleimageview:1.3.0'
    //voley
    implementation 'com.android.volley:volley:1.0.0'
    //gson
    implementation 'com.google.code.gson:gson:2.6.2'
    //sdp
    implementation 'com.intuit.sdp:sdp-android:1.0.5'
    //ripple effect
    implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
    //jsoup
    compile 'org.jsoup:jsoup:1.11.1'
}

xml

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/drawer_layout"
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    android:fitsSystemWindows="true">

    <include layout="@layout/include_list_viewpager"/>


    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_height="match_parent"
        android:layout_width="wrap_content"
        android:layout_gravity="start"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header"
        app:menu="@menu/drawer_view"/>

</android.support.v4.widget.DrawerLayout>

任何帮助将不胜感激。

【问题讨论】:

  • 项目从某处获得颜色,请仔细检查代码是否您声明粉红色更改它并再次运行。也许检查你的 res > values > colors > colorAccent
  • 它在所有其他 androids 操作系统中都可以正常工作
  • 更新 compileSdkVersion 并将以下代码放入项目 gradle subprojects {configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support ') { if (!requested.name.startsWith("multidex")) { details.useVersion '27.1.1' } } } } }
  • 这不是编译问题,这只是您的编码显示 java 文件中的错误
  • 你的问题在这里解决了:stackoverflow.com/questions/42700908/…

标签: android navigation-drawer android-8.0-oreo


【解决方案1】:

关于“错误所有库必须使用相同版本”的错误,请确保所有compileSDK,支持库,构建工具使用相同的版本,例如:27.x.x

导航项的颜色也可以通过app:itemTextColor来控制。还值得注意的是您的应用中使用的主题,因为它还可以控制颜色。请参阅 Android O 效果如何。否则对于 Android o 可以覆盖 itemTextColor。

【讨论】:

    【解决方案2】:

    请检查values 文件夹中的颜色。通常菜单从那里获取颜色。

    如果您无法弄清楚,请从那里发布代码,以便我们检查颜色中发生的情况以及来自哪里。

    最好的问候,

    迪米塔尔·格奥尔基耶夫

    【讨论】:

      【解决方案3】:

      使用 app:itemIconTint 更改颜色图标,使用 app:itemTextColor 更改文本颜色,在您的 xml 中的 NavigationView 属性中,如下所示:

      <android.support.design.widget.NavigationView
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_gravity="start"
              android:fitsSystemWindows="true"
              android:id="@+id/nav_view"
              app:itemIconTint="@color/material_blue_grey_80"
              app:itemTextColor="@color/material_blue_grey_80"
              app:headerLayout="@layout/drawer_header" />
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-04
        • 1970-01-01
        • 1970-01-01
        • 2015-01-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多