Blackberry 透明的 PopupScreen

本文介绍了一个 BlackBerry 应用程序的 UI 绘制示例,包括使用自定义颜色绘制文本,以及如何实现背景的半透明效果。示例通过 Java 代码展示了如何创建一个带有特定布局的弹出视图,并提供了绘制红色文本 Just do it 的方法及设置背景透明度的技术细节。
先看图片吧

[img]http://dl.iteye.com/upload/attachment/203824/03ced82a-b7d5-30d6-8cc6-f0e3e2911306.jpg[/img]

然后看主类代码

import net.rim.device.api.ui.Color;
import net.rim.device.api.ui.Graphics;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.container.FlowFieldManager;
import net.rim.device.api.ui.container.PopupScreen;

public class PopupView extends PopupScreen {

public PopupView() {
super(new FlowFieldManager(Manager.FIELD_HCENTER));
}

protected void paint(Graphics g) {
g.setColor(Color.RED);
g.drawText("Just do it", 0, 0);
}

public void _drawAlpha(int _x, int _y, int _width, int _height, int _color,
Graphics g) {
int _array[] = new int[_width * _height];
for (int i = 0; i < _array.length; i++) {
_array[i] = _color;
}
g.drawARGB(_array, 0, _width, _x, _y, _width, _height);

}

protected void paintBackground(Graphics graphics) {
// super.paintBackground(graphics);
_drawAlpha(0, 0, this.getWidth(), this.getHeight(), 0X66223311,
graphics);
}

protected void sublayout(int width, int height) {
// super.sublayout(width, height);
this.setPosition(0, 12);
this.setExtent(130, 30);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值