作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的应用程序中,我包含了这个库 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/
我正在玩 JavaFX 3D,我有 this 3Dconnexion peripheral它已经放在抽屉里至少一年未使用了,我想用 Java 捕获它的输入。 当我插入它时,我看到一个新文件:/dev/
在我的应用程序中,我包含了这个库 https://github.com/armcha/Space-Navigation-View用于底部导航和添加回收器 View 滚动行为 我在 gradle 文件
我正在 Linux 下使用 Qt 4.8 开发 3D 应用程序。现在我需要支持 3d 鼠标 (3Dconnexion SpaceNavigator)。它附带的 SDK 相当老派,使用 X11 来检索事
我是一名优秀的程序员,十分优秀!