gpt4 book ai didi

android - 带有 SpinnerWheel 库的 CardsLib - 滑动时获取宽度和高度必须 > 0

转载 作者:行者123 更新时间:2023-11-30 02:50:11 25 4
gpt4 key购买 nike

我正在构建一个同时使用 android-spinnerwheel 和 cardsLib 库的应用程序。SpinnerWheel 工作得很好,但是当我尝试使用滑动来删除 cardsLib 的功能时,spinnerWheel 出现了问题。错误是这样的:

06-21 10:43:04.873  17102-17102/com.bitcoinwatcher.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalArgumentException: width and height must be > 0
at android.graphics.Bitmap.createBitmap(Bitmap.java:638)
at android.graphics.Bitmap.createBitmap(Bitmap.java:620)
at antistatic.spinnerwheel.AbstractWheelView.recreateAssets(AbstractWheelView.java:185)
at antistatic.spinnerwheel.AbstractWheel.onLayout(AbstractWheel.java:457)

我想我需要以某种方式告诉轮子它被删除了,但我无法找到具体的方法。即使我设法这样做,它也发生在我实现之前:

    @Override
public void onSwipe(Card card) {
}

@Override
public void onUndoSwipe(Card card) {
}
}

最佳答案

好吧,解决方案很简单。看起来 CardsLib 连续绘制 slider ,即使 slider 不可见,导致它以位图宽度/高度 0 绘制。添加以下安全检查

if (width == 0 || height == 0)
return;

AbstractWheelView.java 解决了这个问题。所以总而言之,

protected void recreateAssets(int width, int height) {
if (width == 0 || height == 0)
return;
mSpinBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
mSeparatorsBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
setSelectorPaintCoeff(0);
}

关于android - 带有 SpinnerWheel 库的 CardsLib - 滑动时获取宽度和高度必须 > 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24339576/

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