Android Question Can View methods/properties in the Designer be accessed from code?

Indy

Active Member
Licensed User
Longtime User
Hi All,

Is there a way of accessing methods that are available in the Designer's script section from code? For example, I really like the HorizontalCenter method for controls (views), which takes away the hassle of having to work this out manually. Also, I like the Properties section, which seems to make setting/configuring controls a breeze. I don't know about others but, I find it somewhat time consuming having to do all this by manually. Normally I try and use the Designer whenever possible, however, on my latest project I had to resort to coding most of the setup because I used a scrollview which had child views that cannot be added from within the designer. I'm also very much interested in the Radius property for buttons but can't find an way of doing that from code.

I'd be interested in any help/pointers.

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can implement the ScrollView content in another layout and then load it to the ScrollView. No need to do it by code: https://www.b4x.com/android/forum/t...-a-panel-higher-than-the-screen.9539/#content

There is no HorizontalCenter property however you can create a similar method:
B4X:
Sub SetHorizontalCenter(v As View, x As Int)
v.Left = x - v.Width / 2
End Sub

I'm also very much interested in the Radius property for buttons but can't find an way of doing that from code.
Are you referring to the Corners Radius?

Changing the buttons drawables is a bit more complicated in code. Search for StateListDrawable.
 
Upvote 0
Top