Android Question TabStrip Slide/Refresh messes up Buttons with ColorDrawable Backgrounds


New Member
This is a default B4A project, however I assume that the same result would occur with B4XPages.
It seems that this behavior is specific to how I have laid out the TabStrip and controls
as I could not reproduce it with simpler layouts.

Where tested:
Samsung Galaxy S5 and Pixel 5

Applies to:
Buttons that have their backgrounds set with ColorDrawable objects
and their text color set by user code.

What happens:
-If you scroll the pages eventually the Button displays get altered in different ways.
-It occurs more rapidly with a TabStrip Refresh
Typically one or more of the following happens:
-The border gets extended out from the button
-Part of the border gets removed
-Text gets shifted
If you press on the button it fixes itself
Not all Buttons always get affected

What I tried:
Spent about 4 days narrowing the problem down to the attached test setup.
Tried to re-create the problem with other simpler code and display setups but could not.
Searched the forum to see if this unique situation had been reported, I found nothing.

How to Reproduce:
-Run the attached B4A application
-Go to Tab3
-Refresh the screen using the pulldown menu item "Test"
-Tab3 buttons will have their borders shifted on the right and bottom and will be gray instead of black

Possible work arround:
Do not use ColorDrawable Backgrounds from code on the TabStrip?

Hopefully someone has a better alternative.


  • Test For TabStrip
    24 KB · Views: 119


Licensed User
Longtime User
Hopefully someone has a better alternative.
When you use ColorDrawable property each button has to have its own drawable unless they are the same size. Color drawable is not reusable. That is why when you refresh with the menu item ‘Test’ the borders of the smaller buttons expand and inherit the larger buttons size and color drawable.
As a test, if you comment all the lines that have = m_cdWhiteBlack except for the smaller buttons in Tab3 that are of equal size, when you press the menu item ‘Test’, those buttons will not expand
Upvote 0


New Member
I kinda thought there was a simple reason and it makes sense once someone points it out to you.
Thank you, your response is much appreciated.
Upvote 0