开发者

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. O.S. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜