Problem with GradientDrawable as Background

Bernd68

Member
Licensed User
Longtime User
Hi all,

i have 2 problems with the Background of Label and Panel.
1. I set the Background with a GradientDrawable which is a nice effect.

But now using 4 Panels, 1 "visible = true" and 3 "visible = false", i have seen, that, after setting a panel which was "visible = true" to "visible = false" and back in to "visible = true", the GradientDrawables used as Background resizes itsself !?

2nd. I can't scroll down to the end of the ScrollView.

Maybe there is a bug in my code? I've have attached two screenshots where you can see this effect, and also the project which i hope someone could review.

To reproduce this with the example attached
After clicking start on the first panel, you choose a book on the second panel and on the third panel you press the top right symbol 2 twice.

Thx for you help
 

Attachments

  • gdraw_initial.png
    gdraw_initial.png
    46.3 KB · Views: 525
  • gdraw_lost.png
    gdraw_lost.png
    45.5 KB · Views: 503
  • booksample.zip
    26 KB · Views: 376
Last edited:

admac231

Active Member
Licensed User
Longtime User
1. I can't tell you why this happens but if you move this:
B4X:
   lblBooksName.Background = gradBack
   lblBooksName2.Background = gradBack
   pnlivList.Background = gradBack
   pnlivOne.Background = gradBack
   lbl.Background = gradBack
from pnlivOne_click to Activity_Create (under 'Build_Book_List' line #86) and remove it completely from pnlivList_click it solves the problem.

2. The panel that contains the scrollview (pnlBookList) has 100%y height. So when you use this line (#85):
B4X:
pnlBookList.AddView(scvSt,0,62,pnlBookList.Height-62,100%y)
You are setting the scrollview to be 100%y of the panel. Which would be fine except its Top is 62. So the bottom of the scrollview is effectively 100%y+62. So 62 pixels will be cut off.

You can fix that by either changing the scrollview height to 100%y-62 or - the better option - setting pnlBookList top to 62. I say this is better because it will make it much, much easier to edit and/or add later on. Actually, I would recommend you do that with the other panels as well.
 
Upvote 0

Bernd68

Member
Licensed User
Longtime User
Corner radius gets Lost

Hi admac 231,

i followed your advice and it solved the original problem posted.
Thanks for looking into it.

But now the corner radius on the top elements gets lost on the
top right, left bottom and right bottom. Still very strange behaviour.

I have attached 2 screenshoots where you can see it.

Anyone an idea, how to solve it? :sign0163:
 

Attachments

  • corner_rad.png
    corner_rad.png
    22.7 KB · Views: 428
  • corner_rad_lost.png
    corner_rad_lost.png
    22.7 KB · Views: 423
Upvote 0

klaus

Expert
Licensed User
Longtime User
Here you are, attached a modified version.

You must define at least one different GradientDrawble for each View with a different size. Otherwise all views point to the same object and if you set it to a view it will change in all the other views. That's the reason why in some cases you got small backgrounds and also why you lost the rounded corners.

In the pnlivList_click and pnlivOne_click routines you should remove all the Background settings no need.

Best regards.
 

Attachments

  • booksample1.zip
    26 KB · Views: 421
Upvote 0
Top