我的问题是我有一个带有 2 色背景的表单;在顶部我有一个 bg 透明文本字段。当它在模拟器中渲染时,它看起来很好,因为 TextField 位于背景中颜色相遇的点上(根据字段 2)。
但是当我单击字段 3 时,文本字段呈现出仅由我的一种背景颜色组成的纯色背景列,而我希望它保持透明。
背景由深蓝色的 LayeredLayout 组成,然后我在下半部分有一个浅蓝色图形:
class RectangleComponent extends Component {
private int bottomColour;
protected void setBottomColour(int colour) {
bottomColour = colour;
}
@Override
protected Dimension calcPreferredSize() {
return new Dimension(250, 250);
}
@Override
public void paint(Graphics g) {
g.setColor(bottomColour);
int[] int_x = new int[] { 0, getWidth(), getWidth(), 0 };
int[] int_y = new int[] { (int) (getHeight() / 2.5), ((int) (getHeight() / 2.5)) + 150, getHeight(),
getHeight() };
g.fillPolygon(int_x, int_y, 4);
}
我的文本字段是:
public class TextCustom extends TextField {
public TextCustom(String hint, String controlName, int maxChars) {
Border border = Border.createCompoundBorder(null, Border.createLineBorder(1, 0xffffff), null, null);
setName(controlName);
setUIID("v2_Label11LightPadMarg");
getAllStyles().setBorder(border);
setHint(hint);
getHintLabel().setUIID("v2_Label11LightPadMarg");
getHintLabel().getAllStyles().setFgColor(0xffffff);
getHintLabel().getAllStyles().setBgTransparency(0);
getHintLabel().setAlignment(Component.TOP);
getAllStyles().setBgTransparency(0);
getAllStyles().setFgColor(0xffffff);
getSelectedStyle().setBgTransparency(0);
setCursorPosition(0);
setMaxSize(maxChars);
setColumns(maxChars);
getAllStyles().setMarginLeft(20);
getAllStyles().setMarginRight(20);
}
}
谢谢
最佳答案
看起来这是模拟器上的问题。在 Android 设备上似乎没问题。结束。
关于java - Codenameone 中图形背景时 TextField 背景透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51849995/