I’m using ZK6, and I would like to change my UI component according to orientation of the mobile device.
In ZK component reference : Tablet Devices/Events/ClientInfoEvent , there is a getOrientation() method in ClientInfoEvent. However, I did not see this method in the class, nor could I find any information about this method. (see update)
Right now I am using this piece of code to adjust component size when device orientation changed.
@Override
public void doAfterCompose(Groupbox comp) throws Exception {
super.doAfterCompose(comp);
comp.addEventListener(Events.ON_CLIENT_INFO, new EventListener<ClientInfoEvent>() {
@Override
public void onEvent(ClientInfoEvent event) throws Exception {
getSelf().setHeight(event.getScreenHeight() + "px");
getSelf().setWidth(event.getScreenWidth() + "px");
}
});
}
But I’m not quite satisfy with it because it require server to update the component, and I still don’t know what orientation it is.
So, how do I know orientation ? and what is a better way to adjust component size according these information ?
I use android emulator to test, if that matters.
UPDATE
I notice that getOrientation() are implement in version 6.5.0, which is not from a stable release.
Since 6.5.0 has been released a while, I decide to answer this question.
Basically,
ClientInfoEventnow provide information about orientation, and alsodevice pixel ratio
so now we can write code like this :
For re-size component, I wrote some client side code to adjust widget width/height at client side, and use java code to ask server to update component if necessary.