我試圖更改特定容器的背景顏色與下面這行代碼:代號一個容器背景色
Container container = new Container(new BorderLayout());
container.getStyle().setBgColor(0x99CCCC);
但沒有任何反應,我用也repaint()
也沒什麼。與setBgTransparency(0)
我試圖更改特定容器的背景顏色與下面這行代碼:代號一個容器背景色
Container container = new Container(new BorderLayout());
container.getStyle().setBgColor(0x99CCCC);
但沒有任何反應,我用也repaint()
也沒什麼。與setBgTransparency(0)
如果你想格式化容器或改變容器的風格,那麼你只需要在容器的設計器中創建UIID,在這裏你可以格式化背景顏色,邊距,填充等。必須創建UIID並將其應用於特定的容器。
例如: -
Container container = new Container();
container.setUIID("Container_uiid_name");
,你達到了預期的輸出。
setBgTransparency(0)使容器透明,所以setBgTransparency爲255使其不透明。希望下面的代碼將幫助您
Container container = new Container(new BorderLayout());
container.getStyle().setBgColor(0x99CCCC);
container.getStyle().setBgTransparency(255);
在CodeNameOne三個步驟,有一個漸變色的容器: 1. getUnselectedstyle 2. setBackgroundType: 既可爲: BACKGROUND_GRADIENT_LINEAR_HORIZONTAL BACKGROUND_GRADIENT_LINEAR_VERTICAL ...
setBackgroundGradientStartColor and EndColor (如果您希望沒有漸變,您應該爲StartColor和EndColor製作相同的顏色)
Container Container1 = new Container();
Container1.getUnselectedStyle().setBackgroundType(Style.BACKGROUND_GRADIENT_RADIAL);
Container1.getUnselectedStyle().setBackgroundGradientEndColor(0xFFBCCA);
Container1.getUnselectedStyle().setBackgroundGradientStartColor(0xFFBCCA);
組件背景可以是棘手的。有些事情要考慮:
0
那麼它什麼並不重要的bgcolor設置優先於bgcolor(不)因此,要覆蓋所有基地,你可以這樣做:
myComponent.getAllStyles().setBorder(Border.createEmpty());
myComponent.getAllStyles().setBackgroundType(BACKGROUND_NONE);
myComponent.getAllStyles().setBgTransparency(255);
myComponent.getAllStyles().setBgColor(myColor);
或者使用與ComponentSelector類的流暢API:
$(myComponent)
.setBorder(Border.createEmpty())
.setBackgroundType(BACKGROUND_NONE)
.setBgTransparency(255)
.setBgColor(myColor);
它好工作。謝謝 –
歡迎,很高興幫助你? –