gpt4 book ai didi

android - 无法膨胀行为子类 com.luseen.spacenavigation.SpaceNavigationViewBehavior

转载 作者:行者123 更新时间:2023-11-30 00:00:52 26 4
gpt4 key购买 nike

在我的应用程序中,我包含了这个库 https://github.com/armcha/Space-Navigation-View用于底部导航和添加回收器 View 滚动行为

<com.luseen.spacenavigation.SpaceNavigationView
android:id="@+id/space"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:space_background_color="@color/colorPrimary"
app:active_item_color="@color/colorTextPrimary"
app:inactive_item_color="@color/colorWhite"
app:centre_button_color="@color/colorAccent"
app:centre_button_icon="@drawable/ic_camera_white_24dp"
app:inactive_centre_button_icon_color="@color/colorWhite"
app:layout_behavior="com.luseen.spacenavigation.SpaceNavigationViewBehavior" />

我在 gradle 文件中启用了 mutidex。没有为库添加 progaurd 规则。他们没有提到要包括的内容。现在这在 Debug模式下工作正常。在 Release模式下,这会失败并出现以下错误

Caused by android.view.InflateException
Binary XML file line #40: Could not inflate Behavior subclass com.luseen.spacenavigation.SpaceNavigationViewBehavior
Caused by java.lang.RuntimeException
Could not inflate Behavior subclass com.luseen.spacenavigation.SpaceNavigationViewBehavior
android.support.design.widget.CoordinatorLayout.parseBehavior (SourceFile:628)
android.support.design.widget.CoordinatorLayout$LayoutParams. (SourceFile:2795)
android.support.design.widget.CoordinatorLayout.generateLayoutParams (SourceFile:1703)
android.support.design.widget.CoordinatorLayout.generateLayoutParams (SourceFile:112)
android.view.LayoutInflater.rInflate (LayoutInflater.java:860)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
android.view.LayoutInflater.inflate (LayoutInflater.java:377)
android.support.v7.app.AppCompatDelegateImplV9.setContentView (SourceFile:287)
android.support.v7.app.AppCompatActivity.setContentView (SourceFile:139)
com.example.MainActivity.onCreate (SourceFile:77)
android.app.Activity.performCreate (Activity.java:6687)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1140)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2631)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2743)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1490)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6165)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:888)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:778)
Caused by java.lang.ClassNotFoundException
Didn't find class "com.luseen.spacenavigation.SpaceNavigationViewBehavior" on path: DexPathList[[zip file "/data/app/com.example.dev-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.dev-1/lib/arm, /data/app/com.example.dev-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib]]
dalvik.system.BaseDexClassLoader.findClass (BaseDexClassLoader.java:56)
java.lang.ClassLoader.loadClass (ClassLoader.java:380)
java.lang.ClassLoader.loadClass (ClassLoader.java:312)
android.support.design.widget.CoordinatorLayout.parseBehavior (SourceFile:621)
android.support.design.widget.CoordinatorLayout$LayoutParams. (SourceFile:2795)
android.support.design.widget.CoordinatorLayout.generateLayoutParams (SourceFile:1703)
android.support.design.widget.CoordinatorLayout.generateLayoutParams (SourceFile:112)
android.view.LayoutInflater.rInflate (LayoutInflater.java:860)
android.view.LayoutInflater.rInflateChildren (LayoutInflater.java:821)
android.view.LayoutInflater.inflate (LayoutInflater.java:518)
android.view.LayoutInflater.inflate (LayoutInflater.java:426)
android.view.LayoutInflater.inflate (LayoutInflater.java:377)
android.support.v7.app.AppCompatDelegateImplV9.setContentView (SourceFile:287)
android.support.v7.app.AppCompatActivity.setContentView (SourceFile:139)
arrow_right
com.example.MainActivity.onCreate (SourceFile:77)
android.app.Activity.performCreate (Activity.java:6687)
android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1140)
android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2631)
android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2743)
android.app.ActivityThread.-wrap12 (ActivityThread.java)
android.app.ActivityThread$H.handleMessage (ActivityThread.java:1490)
android.os.Handler.dispatchMessage (Handler.java:102)
android.os.Looper.loop (Looper.java:154)
android.app.ActivityThread.main (ActivityThread.java:6165)
java.lang.reflect.Method.invoke (Method.java)
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:888)
com.android.internal.os.ZygoteInit.main (ZygoteInit.java:778)

最佳答案

我有解决方案:-

package com.luseen.spacenavigation;

import android.content.Context;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.support.v4.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;

/**
* Created by Chatikyan on 13.10.2016.
*/
public class SpaceNavigationViewBehavior<V extends View> extends CoordinatorLayout.Behavior<V> {

public SpaceNavigationViewBehavior(Context context, AttributeSet attrs) {
super();
}

public SpaceNavigationViewBehavior() {
super();
}

@Override
public boolean layoutDependsOn(CoordinatorLayout parent, V child, View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, final V child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
return true;
}

@Override
public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, V child, View directTargetChild, View target, int nestedScrollAxes) {
// Ensure we react to vertical scrolling
return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
|| super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
}

@Override
public void onNestedScroll(final CoordinatorLayout coordinatorLayout, final V child,
final View target, final int dxConsumed, final int dyConsumed,
final int dxUnconsumed, final int dyUnconsumed) {
super.onNestedScroll(coordinatorLayout, child, target, dxConsumed, dyConsumed, dxUnconsumed, dyUnconsumed);
if (dyConsumed > 0) {
Utils.makeTranslationYAnimation(child, child.getHeight());
} else if (dyConsumed < 0) {
Utils.makeTranslationYAnimation(child, 0);
}
}
}

关于android - 无法膨胀行为子类 com.luseen.spacenavigation.SpaceNavigationViewBehavior,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49964264/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com