我要對齊的自定義按鈕字段(中星截圖)到市中心的一條水平經理的HFM黑莓 - 現場 - 水平對齊
final HorizontalFieldManager _navigation = new HorizontalFieldManager(HorizontalFieldManager.NO_VERTICAL_SCROLL | HorizontalFieldManager.FIELD_VCENTER | Field.USE_ALL_WIDTH)
{
protected void paint(Graphics graphics)
{
graphics.setGlobalAlpha(100);
int[] xInds = new int[]{0, getExtent().width, getExtent().width, 0};
int[] yInds = new int[]{0, 0, getExtent().height, getExtent().height};
final int[] cols = new int[]{Color.WHITE, Color.WHITE, color_computacenter_light_blue, color_computacenter_light_blue};
graphics.drawShadedFilledPath(xInds, yInds, null, cols, null);
super.paint(graphics);
}
protected void sublayout(int maxWidth, int maxHeight)
{
super.sublayout(maxWidth, maxHeight);
setExtent(maxWidth, navigation_vertical_manager_height);
}
};
定義
定製領域(部分)
public class NavigationButton extends Field
{
private String label;
Bitmap img;
int horizontalPadding = 4;
int verticalPadding = 10;
static int height;
static int weight;
ToolTip _tooltip;
public NavigationButton(String name, Bitmap img)
{
label = name;
this.img = img;
this.height = img.getHeight() + 4;
this.weight = img.getWidth() + 2;
}
public NavigationButton(String name, Bitmap img, long style)
{
super(style);
label = name;
this.img = img;
this.height = img.getHeight() + 4;
this.weight = img.getWidth() + 2;
}
protected void layout(int maxWidth, int maxHeight)
{
setExtent(maxWidth, maxHeight);
// setExtent(Math.min(weight, maxWidth), Math.min(height, maxHeight));
}
protected void paint(Graphics graphics)
{
// Draw background
graphics.setGlobalAlpha(255);
if(isFocus())
{
graphics.setColor(0x005AA1);
graphics.drawRoundRect(0 ,0 , weight + 1, height + 1, 2, 2);
}
if (img != null)
{
graphics.drawBitmap(0, 0 , img.getWidth(), img.getHeight(), img, 0, 0);
}
}
[...]
任何想法,我做錯了什麼?!
謝謝!
你能更明確的瞭解你想要什麼樣的行爲,以實現和你」真的看到了嗎?屏幕截圖很好! – 2009-07-07 18:07:52