Trying to display a hovering label on top of my ListField. The Label should be a round-rect and has a semi-transparent black bgcolor. I got the label and text to display and everything, but the bgcolor is solid black. The idea is that the hovering label will appear on top of the items in ListField.
here is my code
Code:
public class MyListField extends ListField {
protected void paint(Graphics g){
super.paint(g);
if(this.getSize() > 0)
this.paintFloatingText(g);
}
protected int getVerticalScroll(){
Manager manager = this.getManager();
int scrollPos = -1;
if(manager != null)
scrollPos = manager.getVerticalScroll();
return scrollPos;
}
private void paintFloatingText(Graphics g){
XYRect floatingRect = new XYRect(100,100,70,30);
// since the Field is scrollable, a y offset is need to make sure the label always displays on the same position on the screen
int offset_x = 0;
int offset_y = this.getVerticalScroll();
Font fnt = this.floatingLabelFont;
//g.setColor(UIParameters.floating_label_bgColor);
// set the color as black semi-transparent fror background
g.setColor(0xCC000000);
int arc = Math.min(floatingRect.width,floatingRect.height)/2;
g.fillRoundRect(offset_x + floatingRect.x ,offset_y + floatingRect.y, floatingRect.width,floatingRect.height,arc,arc);
//g.setColor(UIParameters.floating_label_fgColor);
// set the color as white for text
g.setColor(0x00FFFFFF);
g.setFont(fnt);
// Calculate the left-top margins to center the text display
int margin_x = (int)((floatingRect.width - fnt.getAdvance(this.label))/2);
int margin_y = (int)((floatingRect.height - fnt.getHeight())/2);
g.drawText(this.label, offset_x + floatingRect.x+margin_x, offset_y + floatingRect.y + margin_y, Graphics.TOP | Graphics.LEFT);
}
}