Android Question Dynamic default values in designer

Informatix

Expert
Licensed User
Longtime User
No. However you don't need it in this case.
???
Yes I need it. I set some default values to the value returned by the system and I need to express them in pixels, like in my example. My users expect to set a divider height or a minimum distance for a swipe gesture with a value like 1%y or 3dip. It's what they are used to with B4A.
Note that the question concerns only properties that has no relation with the layout or the screen.
I want to be consistent with the values set by default when creating the view by code but it seems I cannot for now.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The user will set the value to 3 and your code will convert it to 3dip. This is how the designer works with all controls, not just with custom views.

ScrollView for example:
SS-2016-02-22_12.58.11.png


The corner radius, border width and Inner Height values will all be scaled similar to how dip units work.
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Ok, but my problem is to set the default values when they are not constants, when they are based on system settings or computations. By default, my minimum distance for the swipe gesture, for example, is the value set by the OS. Setting it to 0 because I cannot read the value in the designer is stupid, so I'm stuck. I have to remove the property from the designer...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The same layout file will be loaded on different devices with different versions. It doesn't make sense to read the default value of a specific device.

You have two options:
1. Decide that a specific value such as -1 behaves as the default value.
2. Add a Boolean field that if set then the default value will be used (and the other field will be ignored).

You will be able to set the default value in the library code.
 
Upvote 0
Top