LWUIT:设计按钮样式 [英] LWUIT: Styling a Button

查看:80
本文介绍了LWUIT:设计按钮样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个J2ME LWUIT应用程序,我试图更改按钮的宽度和背景颜色.该按钮位于BoxLayout中.我正在使用这样的代码:

I have a J2ME LWUIT app and I'm trying to change the width and background color of a button. The button is in a BoxLayout. I'm using code like this:

    btnLogout.setPreferredW(210);
    btnLogout.getStyle().setFgColor(0x00dcc5);
    btnLogout.getStyle().setBgColor(0x302d36);

似乎只有setFgColor行有效.宽度保持不变,背景保持白色.如何更改按钮的样式?其他组件(标签,文本字段等)都没有这个问题

Only the setFgColor line seems to work. The width remains unchanged and the background remains white. How can I change the style of the button? I haven't had this problem with other components (labels, text fields, etc...)

推荐答案

如果您使用的是诺基亚sdk 2.0来构建您的应用,则应该知道Button和本机元素(复选框,组合框等)样式是系统预先定义的,因此您无法使用此方法更改本机背景.

If you are using the nokia sdk 2.0 to build your app, you should know that the Button's and native elements (Checkbox, ComboBox, etc)style is predefined by the system, so you can't change the native background using this methods.

我不建议您更改此值.如果要按照诺基亚S40指南构建应用程序,则必须保持原生元素不变.

I don't recommend you to change this values. If you want to build an app following the Nokia S40 guidelines, you must keep the native elements as they are.

如果您仍想更改此背景.

您必须打开项目中附带的.res文件(如果您已自定义.res ...如果您使用的是诺基亚sdk中的.res ...您必须找到该库的源代码(是诺基亚页面),您可以在其中找到.res).在.res文件中,您可以为自定义Button创建新样式,然后在代码中,必须使用组件中的setUIID方法将其设置为Button.在.res文件中设置.

You must open the .res file attached to your project (if you have made a custom .res...if you are using the .res from the Nokia sdk...you must find the source code for the library (is nokia page) and there you can find the .res). In the .res file you can create a new style for your custom Button, and later in the code you must set it to your Button, using the setUIID method in your component....with the name that you have set in the .res file.

这篇关于LWUIT:设计按钮样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆