I am trying to add an icon to the title/ title bar.
Changing the title itself with code works fine :
setTitle("Testing");
Yet I can't figure out a way to add an icon to it. Here is what I have tried, with no avail:
Image img = Image.createImage("/kalender.png");
getTitleComponent().setIcon(img);
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, "TitleCommand", 3);
getTitleComponent().setIcon(icon);
Any help would be appreciated.
setTitleComponent will solve it as soon in below
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_SEARCH, "TitleCommand", 3);
Label title = new Label(icon);
**setTitleComponent(title);**
[EDIT]
**getToolbar().setTitleComponent(titles);**
This works for me:
Form form = new Form(BoxLayout.y());
Image icon = FontImage.createMaterial(FontImage.MATERIAL_CAKE, "TitleCommand", 5).toImage();
Label tittleButton = new Label("Tittle", icon, "Label");
form.getToolbar().setTitleComponent(tittleButton);
form.getToolbar().setTitleCentered(true);
form.show();
Related
I have a Bot developed in SDK 4. I am using PromptOptions in Dialog as below :
var options = new PromptOptions()
{
Prompt = MessageFactory.Text("Please select the services "),
RetryPrompt = null,
Style = ListStyle.HeroCard,
Choices = GetMainMenuChoices(),
};
I need to style the Hero card which as of now is in rectangle shape. Can I make it look like rounded corner with some color & do some customize style? Thanks.
I have created an application to test the new CN1 CSS support.
The plugin is great and everything works fine and out-of-the-box, except that the material icon on a button does not change its color with the button's text color. It just stays always the same (black) color.
Before using the CSS support, I changed the theme editor's default foreground color setting to reach the material icon, but now the theme editor seems to be dis-attached from the styling and it does not have any effect anymore.
Is there a UIID for the icon or any other way to change the color of the material icon?
Here is my code:
FontImage icon = FontImage.createMaterial(FontImage.MATERIAL_CHECK, "TitleCommand", 3);
Button buttonTest = new Button("Test css");
buttonTest.setUIID("ButtonTest");
buttonTest.setIcon(icon);
And the CSS:
ButtonTest {
color: red;
}
try it
FontImage img = FontImage.createMaterial(FontImage.MATERIAL_THUMB_UP, style);
Just to post a complete answer that might be able to guide someone:
Style style = new Style();
style.setBgColor(ColorUtil.GREEN);
style.setFgColor(ColorUtil.WHITE);
style.setBgTransparency(255);
FontImage imageBack = FontImage.createMaterial(FontImage.MATERIAL_NEXT_WEEK, style);
I am trying to add dynamic labels on groupbox, but my text size which I also created dynamically is only showing half of it on group box.
This is my simple code:
private void AddLabels()
{
List<Label> labels = new List<Label>();
groupBox1.Controls.Clear();
Label l = new Label();
l.Font = new Font(new FontFamily(System.Drawing.Text.GenericFontFamilies.Serif), 30, FontStyle.Bold);
l.Text = "Hello World";
l.Parent = groupBox1;
l.BringToFront();
labels.Add(l);
}
As you notice on my code, my Font Size is 30, but when I run this, only "Hello" text is showing and only half of "Hello" is showing. The word "World" is not showing also.
Just in case you encounter the same problem. I already figured it the day I posted my question and I want to answer this just in case someone is looking for an answer.
Just adjust your label font size and everything will work fine.
I am developing calculator using qt framework. I have put a label for display the entered number and answer so I want to change the color of this label. How can I do that.
label = new QLabel("0",this);//label for the text inputs
label -> setGeometry(QRect(QPoint(75,25),QSize(50,200)));
please help
You can use Qt Style Sheets
QLabel* label = new QLabel("Hello");
label->setStyleSheet("background: red");
setStyleSheet("background-color: white;");
I am trying to create a CCButton named "Start" in cocos2d v3 using CCLableBMFont label as the button image. But I can't seem to get the label to be in the CCButton in v3.
Any help/advice would be appreciated.
I don't think you can apply a CCLableBMFont to a CCButton. Looking at the documentation, the only options available are:
+ (id)buttonWithTitle:(NSString *)title fontName:(NSString *)fontName fontSize:(float)size
or
+ (id)buttonWithTitle:(NSString *)title spriteFrame:(CCSpriteFrame *)spriteFrame
and a couple variations of these two. So I think you will have to settle with a sprite or a label with a TTF font as the button background.
Here's a utility function I added to my current project that does just that:
+(CCButton *)smallButtonWithLabel:(NSString *)button_label;
And the implementation:
+(CCButton *)smallButtonWithLabel:(NSString *)button_label
{
CCButton *button = [CCButton buttonWithTitle:nil spriteFrame:[CCSpriteFrame frameWithImageNamed:#"dlg-sml-btn-bg-s.png"] highlightedSpriteFrame:[CCSpriteFrame frameWithImageNamed:#"dlg-sml-btn-bg-t.png"] disabledSpriteFrame:[CCSpriteFrame frameWithImageNamed:#"dlg-sml-btn-bg-s.png"]];
[button setBackgroundOpacity:0.5 forState:CCControlStateDisabled];
CCLabelBMFont *label = [CCLabelBMFont labelWithString:button_label fntFile:SS_FONT_48_24_MULTI width:button.contentSize.width alignment:CCTextAlignmentCenter];
label.position = ccp(0.5, 0.5);
label.positionType = CCPositionTypeNormalized;
[button addChild:label];
return button;
}
You can modify it a little bit to fit your needs.
Hope this helps.