How to set a Background Image?

307 views
Skip to first unread message

Jean Marc

unread,
Apr 12, 2014, 9:13:05 AM4/12/14
to androi...@googlegroups.com
Hello guys,

I´m trying to set a picture as Background Image, but unfortunately it doesnt work. I may use the wrong command ...
Is there somebody out there who has a code snippet for me?

Schnee Wittchen

unread,
Apr 12, 2014, 9:54:50 AM4/12/14
to androi...@googlegroups.com
Hi Jean Marc,

if you want to set the background for a layout use

    layBar = app.CreateLayout( "Linear", "Vertical,VCenter,FillX" );   
    layBar.SetBackground( "/res/drawable/bar_gray" );

Basically you can set the background of any object, even buttons, but sometimes the results are not satisfying or it simply don't work.

Please note the path to the image or pattern. Above case use the AndroidScript internal files. If you want to use your own file,
please place it in the subfolder "Img" of your script. The filetype should be "png"

    lay.SetBackground( app.GetPath() + "/Img/Tile.png", "repeat" );

Hope this helps.
best regards
Schnee




Jean Marc

unread,
Apr 12, 2014, 11:41:42 AM4/12/14
to androi...@googlegroups.com
Thanks a lot Schnee :)

This really helps me, thank you very much :)

Dave Smart

unread,
Apr 15, 2014, 4:57:08 AM4/15/14
to androi...@googlegroups.com
Hi Guys,

You should be able to leave out the GetPath() bit and just use "Img/Tile.png" as long as your tile.png is in the Img sub folder of your App (which is where the Web IDE will place it).

Regards
David

Reply all
Reply to author
Forward
0 new messages