ShowcaseView - width and height must be > 0

后端 未结 4 1952
北恋
北恋 2020-12-11 21:49

Research has been fruitless because all other references to this error seem to be reliably repeatable; I\'m unable to consistently repeat this error:

08-22 1         


        
相关标签:
4条回答
  • 2020-12-11 22:21

    go to com.github.amlcurran.showcaseview.ShowcaseView and change this method

    private void updateBitmap() {
            if ((bitmapBuffer == null || haveBoundsChanged()) && getMeasuredHeight() > 0 && getMeasuredWidth() > 0) {
                if(bitmapBuffer != null)
                    bitmapBuffer.recycle();
                int width = getMeasuredWidth();
                int height = getMeasuredHeight();
                if(width > 0 && height > 0)
                    bitmapBuffer = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
    
            }
        }
    
    0 讨论(0)
  • 2020-12-11 22:26

    This is a known issue : Github issues when updateBitmap() is called too early.
    This issue comes from Bitmap.createBitmap() method either width or height equals to 0.
    A workaround is to delay the ShowcaseView creation more:

    someView.post(new Runnable() {
        @Override
        public void run() {
            // display ShowcaseView here
        }
    });
    

    You could also change the updateBitmap() method from the library to not create the bitmap if the view width or height is wrong.

    0 讨论(0)
  • 2020-12-11 22:38

    This was a bug in ShowcaseView, and was fixed starting in v5.4.2: https://github.com/amlcurran/ShowcaseView/commit/c79c60dc798f081fb62e48c549c7bdbff8da51b9

    So, you can just update your build.gradle to:

    compile 'com.github.amlcurran.showcaseview:library:5.4.2'

    0 讨论(0)
  • 2020-12-11 22:39

    Had the same problem, and posted my solution in another thread: https://stackoverflow.com/a/25521608/1752670

    I changed the ShowcaseView class slightly

    0 讨论(0)
提交回复
热议问题