-1

I have a project in which i have to fill a glass of Beer with Bubbles & Fizz effect.

I am using a library : https://github.com/andyb129/BeerProgressView & after implementing this library, the animation does not works on arm based devices, i.e. arm64-v8a & armeabi-v7a.

Here is my code: https://drive.google.com/open?id=0B5kjnHTF2m1DWVNfQWtpYmlielk

I tried adding the library as a Module, as well as tried adding library using gradle also.

Also, enquired about issue on GitHub page also: https://github.com/andyb129/BeerProgressView/issues/7

Whereas Sample code is working: https://drive.google.com/open?id=0B5kjnHTF2m1DMXBIR2hwdUVleFU

If anybody can point out my mistake, i will be very grateful to you.

To display the progress: Custom View code is:

 public void setBeerProgress(int beerProgress) {
        mBeerProgress = beerProgress;
        if (mBeerProgress > mMax){
            mBeerProgress = mMax;
        }
        if (mBeerProgress < 0){
            mBeerProgress = 0;
        }
        float pecent = mBeerProgress * 1.0f / mMax;
        mBeerProgressHeight = pecent * mBeerHeight;
        invalidate();
    }

In the above code, mBeerHeight is always 0.

So i searched ahead,

@Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

        mBeerWidth = (int) (getWidth() - mHaftBorderRadius);

        Log.d(TAG, "Pawan getHeight(): "+getHeight());
        mBeerHeight = (int) (getHeight() - mHaftBorderRadius);

        mBorderRectF.set(mHaftBorderRadius, mHaftBorderRadius, mBeerWidth, mBeerHeight);
    }

Here, in the above code, getHeight() is always 0.... :-(

Pawan
  • 533
  • 1
  • 7
  • 31

1 Answers1

0

Finally got the answer:

Referred from: getWidth() and getHeight return zero after onMeasure() (specific devices)

Latest code:

@Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);

//        mBeerWidth = (int) (getWidth() - mHaftBorderRadius);
        mBeerWidth = (int) (getMeasuredWidth() - mHaftBorderRadius);
        Log.d(TAG, "Pawan getMeasuredHeight(): "+getMeasuredHeight());
//        mBeerHeight = (int) (getHeight() - mHaftBorderRadius);
        mBeerHeight = (int) (getMeasuredHeight() - mHaftBorderRadius);




        mBorderRectF.set(mHaftBorderRadius, mHaftBorderRadius, mBeerWidth, mBeerHeight);
    }

getMeasureWidth() & getMeasureWidth() will give you the correct Width & Height.

Community
  • 1
  • 1
Pawan
  • 533
  • 1
  • 7
  • 31