简体   繁体   中英

Dynamic transparent background in my Android App Java

I want to set the background to a transparent image and change the color of the background on an event firing.

I can set the background image to a resource in an xml file, and I can also change the color of a TextView on event firing, but for some reason I can't do both at the same time. Do I need to create a drawable or something?

Also, how do I reference the top level LinearLayout. I'm programming using Eclipse Java EE Galileo with the ADT Plugin and the android sdk. OS android 2.1-update1 (eclair). My friend can do it in actionscript and I have to do it in java to beat him lol.

Well Mike you can get the refrence to root LinearLayout only when you declare android:id in your concerned layout xml file.

Then in your java code

get your LinearLayout l1 = (LinearLayout)findViewById('R.id.....');

then set background using setBackground function for l1 object.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM