Android Question [Solved] cannot get a panel transparent

Pflichtfeld

Active Member
Licensed User
While designing my first app, I set a panel (pnlBasis) covering whole Activitiy Main in Layout "LyBasis". The panel has a gradienddrawable. Looks ok.
I would like this layout put as basis for all my activities for make them look uniform.
In this pnlBasis I want to load activity-specific panels with the necessary views. So I designed another layout ("LyPnlMain") with again a panel (pnlMain) with its color set to #00000000. (If alpha-channel is 0 I assume transparency - is that wrong?) (All Panels B4XView)
But I fail:

B4X:
Activity.LoadLayout("LyBasis")
PnlBasis.LoadLayout("LyPnlMain")
When I load LyPnlMain in PnlBasis, the whole screen turns to dark grey. The Views on PnlMain are ok, but my background is gone.
What am I doing wrong?
 

drgottjr

Expert
Licensed User
Longtime User
i think you want panel.background, not panel.color
B4X:
    Dim transperson As ColorDrawable
    transperson.Initialize(Colors.transparent,0)
    panel.Background = transperson
if i set the color to #00000000, i get the dark gray. if i set the background to transparent, i get see through. i've never understood the difference, but when i want transparent, i go with background and a color drawable.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
think you want panel.background, not panel.color
Not needed.

When you load a layout to a panel the root view ("activity") background is set to the panel. Either change the background in the layouts or set it after you load the layout:
B4X:
pnlBasis.Color = xui.Color_Transparent
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
Thanks Erel, but nothing changes:
Either change the background in the layouts or set it after you load the layout:
B4X:
pnlBasis.Color = xui.Color_Transparent
1. This does not change anything nor does
B4X:
pnlMain.Color=xui.Color_Transparent
do the job.

2. "Change the background in the layouts...": I set the background from the activity in LyPnlMain to #00000000 (is it that, what you mean?), but still no transparence of the second layout.
 
Upvote 0

Pflichtfeld

Active Member
Licensed User
OK Erel, I found it out now myself:
First in activity Main a panel1 over the whole screen. There I handle the colors.
In this a panel2, set to transparent, all that saved as Layer1 (I missed this step in my project, loadet layer2 in panel1, and that was the reason, it did not work.)
A new layer2, with a panel3 all over activity-size.
Load this layer2 in panel2.
Thank you for your help!
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…