底部Naviagtion无法正常工作?

时间:2018-03-16 09:22:30

标签: android xml android-layout bottomnavigationview

我正在使用底部导航我在我的xml中有以下代码以获得底部的nagvigation,但是当我运行应用程序时,我会继续将此设置为异常。

这是我的xml代码

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout  xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.activatic.paychek.HomeActivity">

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="#f1f1f1">

    </FrameLayout>


    <!--<android.support.v4.widget.NestedScrollView
        android:id="@+id/myScrollingContent"
        android:layout_width="match_parent"
        android:layout_height="match_parent">


    </android.support.v4.widget.NestedScrollView>-->
   <android.support.design.widget.BottomNavigationView
        android:id="@+id/bottom_navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:itemBackground="@color/colorPrimary"
        app:itemIconTint="@color/white"
        app:itemTextColor="@color/white"
        app:menu="@menu/bottom_nav_items" />

   <!-- <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        app:menu="@menu/bottom_nav_items" />-->
</RelativeLayout>

这是我面临的例外情况。

java.lang.NoSuchMethodError: No static method combineMeasuredStates(II)I in class Landroid/support/v7/widget/ViewUtils; or its super classes (declaration of 'android.support.v7.widget.ViewUtils' appears in /data/app/com.activatic.paychek-2/base.apk:classes5.dex)
    at android.support.design.internal.BaselineLayout.onMeasure(BaselineLayout.java:69)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19857)
    at android.support.design.internal.BottomNavigationMenuView.onMeasure(BottomNavigationMenuView.java:143)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19857)
    at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715)
    at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:640)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6083)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
    at com.android.internal.policy.DecorView.onMeasure(DecorView.java:689)
    at android.view.View.measure(View.java:19857)
    at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2275)
    at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1366)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1619)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1254)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6337)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:874)
    at android.view.Choreographer.doCallbacks(Choreographer.java:686)
    at android.view.Choreographer.doFrame(Choreographer.java:621)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:860)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6119)
    at java.lang.reflect.Method.invoke(Native Method)

下面是我的build.gradle文件,请找到并告诉我这是我正在使用的所有依赖。

dependencies {
    implementation 'com.google.android.gms:play-services-maps:11.8.0'
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile project(':ccp')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    //    compile 'com.google.android.gms:play-services:11+'
    //    compile 'com.google.android.gms:play-services-auth:11+'
    //noinspection GradleCompatible
    compile 'com.android.support:appcompat-v7:25.0.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
    compile 'com.facebook.android:facebook-android-sdk:[4,5)'
    //noinspection GradleCompatible
    compile 'com.android.support:support-v4:25.3.1'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.squareup:otto:1.3.8'
    compile 'com.squareup.retrofit2:retrofit:2.0.2'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.squareup.okhttp3:logging-interceptor:2.0.2'
    compile 'com.squareup.okhttp:okhttp:2.7.5'
    compile 'com.google.code.gson:gson:2.7'
    //noinspection GradleCompatible
    // compile 'com.google.android.gms:play-services:11.0.4'
    compile 'com.android.support:multidex:1.0.0'

    //noinspection GradleCompatible
    compile 'com.android.support:animated-vector-drawable:25.3.1'
    //noinspection GradleCompatible
    compile 'com.android.support:mediarouter-v7:25.2.0'
    compile 'com.roughike:bottom-bar:1.4.0.1'
    compile 'com.github.ittianyu:BottomNavigationViewEx:1.2.4'
    compile 'com.facebook.android:account-kit-sdk:4.+'
    //noinspection GradleCompatible
    compile 'com.android.support:design:25.0.0'
    compile 'com.google.firebase:firebase-core:11.8.0'
    compile 'com.google.firebase:firebase-messaging:11.8.0'

    //noinspection GradleCompatible
    compile 'com.android.support:recyclerview-v7:25.3.1'
    compile 'com.github.moondroid.coverflow:library:1.0'
    testCompile 'junit:junit:4.12'
    compile 'com.squareup.okhttp3:logging-interceptor:3.9.0'
    compile 'com.jakewharton:butterknife:8.8.1'

    annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
    // compile 'com.google.firebase:firebase-messaging:11.0.4'
    //compile 'com.google.firebase:firebase-crash:11.0.4'
}

任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:-1)

请参阅以下链接了解您的问题

Android new Bottom Navigation bar

https://github.com/roughike/BottomBar

借助此链接,您可以检查代码中的操作。什么是确切的问题。所以你必须将你的代码与这个代码进行比较并检查你做错了什么