Android Question panel with square center transparent

Douglas Farias

Expert
Licensed User
Longtime User
hi all, how can i make a panel 100%x , 100%y on my screen with the center transparent
like this
contraste-simultaneo.jpg



but no gray, transparent??
i have a minimal ideia how *-*, can someone give me a sugestion?
 

sorex

Expert
Licensed User
Longtime User
make the panel transparent if that's possible
add an imageview to the panel
draw a square to the imageview
erase the inner square from the imageview
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
1° i make a panel 10% black

but how to put a square inside this panel and make transparent?
 
Upvote 0

Guardian17

Active Member
Licensed User
Longtime User
Assuming you have an image editor that lets you create PNG files that have transparency, you can create an image that has the center "cut out" (transparent). If you then add a panel and then load that PNG file as the panel's background image, I think that will accomplish what you're looking for.

I've included a sample program below. It loads two panels, Panel1 and Panel2. Panel1 loads a background image of a vase of flowers, and Panel2 loads the "frame" image as the Panel2 background. A Timer is included to first show the overall vase of flowers, then the "frame" panel is made Visible 2 seconds later. If you touch the screen, the frame goes away and re-appears 2 seconds later.

Panel2 must be loaded after Panel1 so that it appears "on top of" the other image.

Hope this helps.
 

Attachments

  • PanelWithTransparentCenter.zip
    227.4 KB · Views: 251
Upvote 0
Top