How can I create a Custom Gauge Field which is better looking? - blackberry

I need to create a custom gauge field which looks slimmer like a Blue thin line filling in.
Any ideas/resources?

There aren't any native BlackBerry controls, but you can create your own custom field and implement a paint() method that draws the gauge using Graphics.fillRoundRect().

Related

Customize TextInputLayout with hint inside TextInputEditText

I'm trying to customize my TextInputLayout to make it like this:
I already tried lots of things using xml attributes but with style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox" but no success, the hint is always at border level with that space(like the default material).
It's possible to achieve this layout only using the TextInputLayout attributes or I'll have to create a custom view? If so, how would I control the hint animation?

Change colorPrimary and colorAccent programmatically for use in ContextThemeWrapper

I'm working on a live event app for a client. There are about 20 view containers that make heavy use of colorPrimary and colorAccent for coloring the views.
The client has just now decided that those colors should be different for each event.
Is there any way for me to use ContextThemeWrapper to simply inject the colorAccent and colorPrimary received from the backend? That way, when I start EventActivity, I can just put in the correct colors, and those would propagate all the way down to the activity's View, Fragment, and Dialog children.
If that's not possible, I guess I will have to go through each View one by one in Java and set the appropriate colors. That's tedious but easy. What's not easy are my shapes defined in XML. For instance, I have a drawable that I use as a button background which is simply a 1dp stroke on a rectangle with rounded corners. The color of the stroke is colorAccent. How would I go about changing that at runtime?

How to prevent a firemonkey form to draw itself (for calling an own drawing function)?

I try to convert an existing OpenGL-Application from VCL-based forms to FMX-based forms in C++ Builder XE3.
For this purpose I use the handle of a Firemonkey-form to create the OpenGL device context and make this form a child of another form to mimic the panel inside the form which I had in my VCL-based application.
The problem is now that after a resize-event or in general after calling Invalidate() the form is rendered with its background. This causes a flickering or even worse: sometimes the background is shown instead of my OpenGL rendered scene.
How can I prevent the repaint of the region at the position of my Firemonkey-OpenGL-form. Alternatively, can I define an Ownerdraw-function or something else?
Please note, that it is no option for me to use a Firemonkey-3d-Form.
Have tried giving the form a transparent background? Then you can paint whatever you want 'over the top'.
The quick way is to set the forms Transparent property to True, but this creates issues with ComboBoxes.
Another way is to place a TRectangle on the form. Set it's StyleName to 'backgroundstyle'. Set it's Fill.Color to claNull. Set Stroke.Thickness to 0. This will replace the default background styling for the form.
If you want to paint your own borders too you'll need to investigate non-client area styling but I don't have a pointer to a good resource at present.
After hours of experimenting I found the solution: The "TCommonCustomForm" has the needed properties: (1) it does not draw itself, (2) it has a handle which can be used for OpenGL initialization.
I hope this information will help others.

Blackberry Rounded Text Boxes

Hi i want to create a login form in blackberry,
I have taken the username and password from the user but i want the username and password to appear inside the round rectangular text box.
But I am not able to draw a round rectangle
Any help?
On BBOS 4.6 and later, you can create a net.rim.device.api.ui.decor.Border object and pass it to a field's setBorder() method. Look at the net.rim.device.api.ui.decor.BorderFactory class to help you construct Border objects, such as with one of its createRoundedBorder() methods.

how is it possible to clear what was painted before?

I'm using Delphi and I'm building my own label component with class TControl.
Before I paint the text according to the properties (such as caption, font, etc.) I want to clear paint rect like there is nothing at the place of component. I mean I want to make it like a glass so that the other components behind it will be displayed; and then paint the text. What should I do to paint other components that are placed behind my label to it?
To do that, you need to do nothing. :-)
When you make a transparent label-like component, you best use the TGraphicControl base class. This is actually little more than a canvas to paint on. Whenever the content should be changed, you call the Invalidate method to repaint your control. This will call the Paint method that you can override. With every repaint, your control will be clear and transparent, except for the parts where you draw stuff in your Paint method.
Unless you override and disable the background painting, then you dont need to do anything. It depends on what base-class you go for. Although you can simply use (in the Paint() method):
Canvas.Brush.Style:=bsSolid;
Canvas.Brush.Color:=self.Color; //If you have a public color property
Canvas.FillRect(ClientRect);
You should also read up on TControlCanvas. Here is a website that deals with this topic more in depth: http://www.delphidabbler.com/tips/75

Resources