问题
I want to to change the header color of nokia lwuit based full touch form and i have tried setTitleComponent method but it is not working. Please also check the following link http://projects.developer.nokia.com/LWUIT_for_Series_40/wiki/UsingSeries40FullTouchFeatures in which it is mentioned we cannot style the header but is it means we cannot change the bgcolor as well or put custom images in the header?
回答1:
Note that when using LWUIT for Series 40 port, the default way of running LWUIT apps is a normal-size canvas in Series 40 full touch devices. Thus the Series 40 chrome shows on top of canvas. And there is no way of customising it (other than the title text).
If you want to provide branding elements to the title, the options are: 1. create an additional lable below the Series 40 headerbar 2. run the application in full-screen. We are planning to create a high-level API for this but currently it is already possible using the following trick: ((GameCanvas) (javax.microedition.lcdui.Display.getDisplay(this)).getCurrent()).setFullScreenMode(true); In the latter option you will of course lose the Series 40 full touch layout.
回答2:
Use lwuit source, you can change method visibility if required, this is example what i used to use gradient color
form.getTitleComponent().getStyle().setBackgroundType(Style.BACKGROUND_GRADIENT_LINEAR_VERTICAL);
form.getTitleComponent().getStyle().setBackgroundGradientEndColor(Color.GRADIENT_END);
form.getTitleComponent().getStyle().setBackgroundGradientStartColor(Color.GRADIENT_START);
form.getTitleComponent().getStyle().setFgColor(Color.WHITE);
form.getTitleComponent().getStyle().setPadding(10,10,0,0);
form.getTitleComponent().getStyle().setFont(font);
Here Color
is my custom class that is used for color code, you can use your one.
来源:https://stackoverflow.com/questions/11960836/how-to-change-nokia-full-touch-lwuit-form-header-color