Is there a way to inject a material icon character inside a regular text paragraph?
So I need something like this: "Some text"+material icon character here+" some more text". And I want this to flow normally, without extra lines.
Thanks.
I suppose that there are several approaches according to the level of generalization of this problem. For example, a complex solution could be an extension of the RichTextView class to support this feature (http://www.codenameone.com/blog/tip-rich-view-revisited.html).
However, a basic approach could be to have two or three Labels inside a Container with a FlowLayout layout. For example, the following code:
Form hi = new Form("Hi World", BoxLayout.y());
Container textWithMaterialIconInside = new Container(new FlowLayout(Component.LEFT));
textWithMaterialIconInside.add(new Label("Some text", "Label"));
textWithMaterialIconInside.add(new Label(FontImage.createMaterial(FontImage.MATERIAL_BACKUP, UIManager.getInstance().getComponentStyle("Label"))));
textWithMaterialIconInside.add(new Label("and other text", "Label"));
hi.add(textWithMaterialIconInside);
hi.show();
generates this content:
Related
I've a textArea with grow limit "2" and alignment "center". I need to hightlight the "Quick Booking" text of the following textArea differently ie. in color, size etc. Since the textArea is aligned center, this hightlighted text may appear anywhere as per the device width. How can I do that?
TextArea ta = new TextArea("Need urgent fix for your car ? We will get to you asap Quick Booking");
ta.setUIID("small");
ta.setEditable(false);
ta.setGrowByContent(true);
ta.setGrowLimit(2);
ta.getAllStyles().setAlignment(Label.CENTER);
How It is now...
How it should be...
That isn't supported. One option is to use a BrowserComponent for this element and format it with HTML. Another is to use a rich text view such as this: https://www.codenameone.com/blog/tip-lightweight-rich-text-view.html
I saw the stack question where it was solved. I didn't find it now otherwise I'd have shared the link. It works though.
homeContainer.add(FlowLayout.encloseCenter(lbl1, new Label("urgent"), new Label("fix"), new Label(" for"), new Label("your"), new Label("car? "), new Label("We"), new Label("will"), new Label("get"), new Label("to"), new Label("you"), new Label("asap "), clickable));
I am afraid this is not supported.I would suggest you to give a look on below article
https://medium.com/#Cuong.Le/android-rich-text-overview-397e6af529d9
Is it possible to automatically "mirror" a GridLayout in a RTL language? I mean that the first column should be on right instead of on left.
I tried it in my app without success.
It does work. I'm guessing you didn't activate the global RTL flag correctly you need to do that early on in the app for it to take effect.
Form hi = new Form("RTL", BoxLayout.y());
Container grid = GridLayout.encloseIn(new Label("1"), new Label("2"), new Label("3"));
Container gridRTL = GridLayout.encloseIn(new Label("1"), new Label("2"), new Label("3"));
gridRTL.setRTL(true);
hi.addAll(grid, gridRTL);
hi.show();
I am trying to specify sidemenu width with the follow code:
Hashtable<String, Integer> h = new Hashtable<>();
h.put("sideMenuSizePortraitInt", 50);
h.put("sideMenuSizeLandscapeInt", 30);
UIManager.getInstance().setThemeProps(h);
But the result has some misplacement, please see the picture. Anybody knows how to fix this?
screenshot
That's a bad idea. This will break your theme entirely as it will replace all existing theming in the app. Theme constants are added in the designer tool by double clicking the res file, selecting the theme and then going to the 5th tab for the constants.
If you insist on doing this thru code I suggest using addThemeProps and not setThemeProps. Theme constants start with the # symbol to signify that they are constants.
enter image description here
We are automating the UI Application, Our UI application have Disabled Text are present, so we need to Validate the Disabled text. Before validating, I have to Print the Disabled text, Please guide me to how to print the text using Geb/Groovy.
Please find the Image of HTML tag which i highlighted is the Disabled text
BNSF0000712570
BNSF0000712570
The selector above will yield multiple results, i.e. elements, if there is more than one element that matches the classes used in the By.cssSelector query.
To get only the element containing "BNSF0000712570", I would suggest you try to get it using the "ext:qtip" attribute instead (which I assume is unique per element containing a disabled text) on the div containing the disabled text:
def myText = $(“div[ext:qtip=‘Id: 0001’]”).text();
println myText;
assert myText == "BNSF0000712570";
#Saurabh Gar: Why would you use the WebDriver "By" class selectors? With Geb you have access to a wide range of simpler ways to write selectors, e.g. like the one used above.
You should try using By.cssSelector as below :-
def text = driver.findElement(By.cssSelector("td.x-grid3-td-elementvalue").text
Or
def text = driver.findElement(By.cssSelector("div.x-grid3-col-elementvalue").text
assert text == "BNSF0000712570"
println text
Note:- If still doesn't get the text need to share table HTML insteadof screenshot that's why, could make a best locator.
Hope it helps..:)
I'm tring to override CreateLabels to insert labels or text in specific points in plotter chart but I need a help in:
1. what does the parameter (ITicksInfo<double> ticksInfo) mean and what should I send to it
2. how to use the return value to add labels to already defined Axis like _stringaxis.LabelProvider
or if there is simpler way to add text in a point please tell,
Many thanks.
Just found the easiest way to add a nice label inside the chart.
CenteredTextMarker label = new CenteredTextMarker();
label.Text = text;
//just dawing a line with one dot tall in the same position you want the label to be
plotter.AddLineGraph(compositeDataSource1,
dptLine,
label,
new PenDescription(ComponentName));
and I'm Hiding the legend and build a customized one my self by doing
plotter.LegendVisible = false;