LayoutPanel - how to set background image?

947 views
Skip to first unread message

Magnus

unread,
Oct 28, 2011, 12:33:27 PM10/28/11
to google-we...@googlegroups.com
Hi,

I have a Layout Panel and I would like a background image.
How can I do that? And how can I make it repeat, horizontally and vertically?

I found that a LayoutPanel does not have a getElement/getStyle method.
So how can I access the element style or how can I realize the background?

Thanks a lot!
Magnus

Ed

unread,
Oct 28, 2011, 1:02:56 PM10/28/11
to Google Web Toolkit
Use @sprite to set the background image and use the image settings in
de ClientBundle to define the h/v repeat.
See: http://code.google.com/webtoolkit/doc/latest/DevGuideClientBundle.html
- Ed

gerry

unread,
Oct 29, 2011, 1:02:35 AM10/29/11
to Google Web Toolkit
Hi,

Try myLayoutPanel.setStyleName("my-layout-style"). And then in the css
add the rule
.my-layout-style { background-image:...}.It will repeat by default,
unless you set background-repeat:"no-repeat".

I think this would work.

Sudhakar Abraham

unread,
Oct 31, 2011, 9:31:58 AM10/31/11
to Google Web Toolkit
In Uibinder specify your image on src attribute of <ui:image> tag,
Inside the <ui:style> attribute specify your @sprite.backgroundPicture
tag. Try the below example.

S. Abraham
www.DataStoreGwt.com
Persist objects directly in Google App Engine

<?xml version="1.0" encoding="UTF-8"?>
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'>

<ui:image field='backgroundPicture' src='easyxbrl_logo_1.png' />

<ui:style>
@sprite .backgroundPicture {
gwt-image: 'backgroundPicture';
float: left;
margin-top:5px;
margin-bottom:5px;
margin-left: 50px;

}
</ui:style>
<g:LayoutPanel styleName="{style.backgroundPicture}"/>
</ui:binder>


Reply all
Reply to author
Forward
0 new messages