@@ -288,25 +288,26 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
288
288
if (changed ) {
289
289
int w = right - left - getPaddingStart () - getPaddingEnd ();
290
290
int h = bottom - top - getPaddingTop () - getPaddingBottom ();
291
+ if (h > 0 ){
292
+ if (mBitmapFG == null ) {
293
+ createBitmapFG (w , h );
294
+ } else if (mBitmapFG .getWidth () != w || mBitmapFG .getHeight () != h ) {
295
+ if (!mBitmapFG .isRecycled ()) {
296
+ mBitmapFG .recycle ();
297
+ }
291
298
292
- if (mBitmapFG == null ) {
293
- createBitmapFG (w , h );
294
- } else if (mBitmapFG .getWidth () != w || mBitmapFG .getHeight () != h ) {
295
- if (!mBitmapFG .isRecycled ()) {
296
- mBitmapFG .recycle ();
299
+ createBitmapFG (w , h );
297
300
}
298
301
299
- createBitmapFG (w , h );
300
- }
302
+ if (mBitmapBG == null ) {
303
+ createBitmapBG (w , h );
304
+ } else if (mBitmapBG .getWidth () != w || mBitmapBG .getHeight () != h ) {
305
+ if (!mBitmapBG .isRecycled ()) {
306
+ mBitmapBG .recycle ();
307
+ }
301
308
302
- if (mBitmapBG == null ) {
303
- createBitmapBG (w , h );
304
- } else if (mBitmapBG .getWidth () != w || mBitmapBG .getHeight () != h ) {
305
- if (!mBitmapBG .isRecycled ()) {
306
- mBitmapBG .recycle ();
309
+ createBitmapBG (w , h );
307
310
}
308
-
309
- createBitmapBG (w , h );
310
311
}
311
312
312
313
mRectSrc .left = 0 ;
@@ -343,6 +344,9 @@ protected void onDraw(Canvas canvas) {
343
344
if (!hasLrc ()) {
344
345
int width = getLrcWidth ();
345
346
int height = getLrcHeight ();
347
+ if (width == 0 || height ==0 ){
348
+ return ;
349
+ }
346
350
@ SuppressLint ("DrawAllocation" )
347
351
StaticLayout staticLayout = new StaticLayout (
348
352
mDefaultLabel ,
@@ -627,11 +631,11 @@ private int findShowLine(long time) {
627
631
}
628
632
629
633
private int getLrcWidth () {
630
- return getWidth () - getPaddingStart () - getPaddingEnd ();
634
+ return Math . max ( getWidth () - getPaddingStart () - getPaddingEnd (), 0 );
631
635
}
632
636
633
637
private int getLrcHeight () {
634
- return getHeight () - getPaddingTop () - getPaddingBottom ();
638
+ return Math . max (( getHeight () - getPaddingTop () - getPaddingBottom ()), 0 );
635
639
}
636
640
637
641
@ MainThread
0 commit comments