Questions about some View objects

klaus

Expert
Licensed User
Longtime User
EditText
No Color parameter in the Designer, has a default color, can be changed by code with the Color parameter.
When the text is higher than the EditText height, how can we get an automatic ScrollBar.
How to set the cursor at the end of the text (ScrollToCaret).
Wouldn't a single Text parameter be enough,
SingleLine when the parameter SingleLine=True
MultiLine when the parameter SingleLine=False
Or hide the non relevant field.
Changing the text in one of the fields changes also the text in the other.
But MultiLine text field doesn't accept multiline texts, CR has no effect. Same for Labels.
How to avoid automatic display of the virtual keybord when EditText gets focus?
How to hide the virtual keyboard in code and in the emulator?

Label
Has a Text and a MultiLine Text field but no SingleLine parameter?
Doesn't have a Color parameter in the Designer? Is transparent by default.
But it's Color parameter can be set by code.
Same for CheckBox, RadioButton, EditText
Do these views also have the Drawable parameter like Buttons, Panels etc.

CheckBox, RadioButton
Default horizontal text alignment is CENTER_HORIZONTAL
I find that for these Views a default LEFT alignment would be more useful.

Button
Depending on the Drawable parameter the size is not the same.
Button size 50/50
Drawable parameter size
Default drawable 43/42 ? There is a transparent frame around. Round corners
Gradient drawable 50/50 ! Round corners
Color drawable 50/50 ! no round corners
Bitmap drawable 50/50 ! no round corners
Bitmap is stretched to the button size, can this be changed like in B4PPC ?
There is a Pressed parameter in the Designer, when true shows the button pressed in the Designer, but has no effect when compiled nor is it available in the IDE. Button2.Pressed=True in the code generates an error.

Best regards.
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
You are raising good points. Some of them are related to features not implemented yet and some are related to the way Android works.
Views like EditText and Button (and others) have a default background which is made of several layers and images. It is not possible to just change the button color for example and get a similar looking button but with a different color.
This is why the round corners get lost when you change the color.

I may change the color implementation (which now doesn't do much, and just switches to ColorDrawable) to be a bit more complex and add round corners.

You can add new lines (in the multiline field) in the designer by pressing Ctrl + Enter.
EditText will include another property named InputType which will affect the virtual keyboard (hide it, show it in numberic mode...). The user can hide it by pressing on the "back" key. This is the key right to the "menu" key in the emulator.

The user can scroll the EditText with his finger by sliding it up or down. There are no "regular" scroll bars.

The drawable property will be added to Label, CheckBox and RadioButton (for EditText a simple drawable is not really useful).
Default horizontal text alignment is CENTER_HORIZONTAL
I find that for these Views a default LEFT alignment would be more useful.
Good point. Will be changed.

Label doesn't need a SingleLine property because it just shows the text you entered. When you change the SingleLine property of an EditText it causes several behavioral changes.

You can set the caret position by changing the SelectionStart property (not sure if it will also scroll the view).

About the Button.Pressed. The Button drawable is a StateListDrawable. StateListDrawable is a drawable that holds other drawables and selects which one to display based on the current state.
Buttons have three states: Enabled, Pressed and Disabled. The designer Pressed property allows you see how the Pressed drawable looks like.
Currently it lacks a description which should specify that this is a designer only property.
Also note that Activity.FullScreen and Activity.IncludeTitle are designer only properties (for technical reasons). You can change these properties under IDE menu - Project - Activity properties.
 

klaus

Expert
Licensed User
Longtime User
Coming back to two of the points I mentioned.

Label
The main question was why having 2 text fields, Text and Multi Line. Wouldn't one be enough because it is multi line by definition (no single line parameter).

Button
Is the Pressed parameter really only readable in Android ?
It would be interesting to be able to set this parameter to True or False by code to manage standard Buttons as personal ToggleButtons with personal images.
Otherwise, how can the images of a button be changed by code ?
Or can the ToggleButton images be changed.

Best regards.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The main question was why having 2 text fields, Text and Multi Line. Wouldn't one be enough because it is multi line by definition (no single line parameter).
The multiline field is enough. However as I see it, in almost all cases labels have a single line and in order to be consistent I'm keeping the single line as well.

There is no Pressed property. It just tells the designer app to show the pressed drawable instead.
You can change the image of a buttons by setting its Drawable property:
B4X:
    Dim bd As BitmapDrawable
    bd.Initialize(LoadBitmap(File.DirAssets, "1.jpg"))
    button1.Background = bd

You can also change the image of a ToggleButton in a similar way.

StateListDrawable (which is not finalized yet) is the best solution for views like ToggleButton. It allows you to set the image for each state.
 

klaus

Expert
Licensed User
Longtime User
How to set the cursor at the end of the text (ScrollToCaret)
You can set the caret position by changing the SelectionStart property (not sure if it will also scroll the view).

I confirm that setting the SelectionStart property to the end of the text scrolls the view down to the end.

Best regards.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Thanks Klaus.
A new update will be available today that will include several of the features we discussed here:
- Color drawable with round corners.
- (designer) Drawable property for Label, CheckBox and RadioButton.
- Gravity property for images. Allows you to change the way the image is displayed (Fill, Center and TopLeft for now).

It will also include a tool to easily generate views and events declarations from the designer.
 
Top