• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

set alpha of only parent

 
Jeet Dholakia
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys,

I have a few textviews inside a linear layout, but when i set the alpha property in linear layout, even the child layouts appear half transparent, how can i set the property only for parent but not the child , either by xml or programatically ?

Regards,
Jeet
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The TextViews must have transparent backgrounds by default. Set their background to something specific.
 
Jeet Dholakia
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you interpreted that differently, i mean , my linear layout has an alpha property of 0.5 because its laid on top of an imageview,to render a better ux, but all the textviews inside linearlayout aren't supposed to have alpha, but that's the default android behavior i guess,so any workarounds? Setting alpha value of textview to 1 doesnt seem to work...
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you provide a sample layout that shows us the problem? That way I can run it and see what exactly you mean.
 
Jeet Dholakia
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sure ,

I'll give the the xml of what i mean , i think you'll get my question asap then




all i want is a 0.5 alpha of parent and 1 alpha of child...
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, if you set android:visibility="invisible" then the entire view group will be invisible, nothing to change that. Also, it looks like the android:alpha attribute is designed to set the alpha for a view group and all its children. So you shouldn't be using it. Instead, set the background color with the alpha you want. Example:


This looks like:

Note that the first text box, I did not set any specific background color, so it inherited the one from the scroll pane. But the second one I set a specific color, so it gets its own alpha channel, and is not hidden. Also note that I put an image in the FrameLayout, and set the ScrollView to have a gray background color so that you could see the alpha effect more clearly.
 
Jeet Dholakia
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks,

this is what i really wanted, especially i'd give a +1 for the wireframe had there been a button for that

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic