Android Question crossed with cross platform


Active Member
Licensed User
I've been struggling with this code for quite sometime in order to make it cross-platform compatible.

b4j label as shown in B4XPagesCrossPlatformProjectsV2_1.pdf documentation is as follows:


HERE all labels are shown to be compatible across platforms
but in actual there are some properties not available in others (like label.setbackground in b4a is not available in b4j)
after having gone back and forth trying to replace label with some other view and finding out that something else is not available in that view,
it brings me here to ask more experience developers on

1. Is there a comprehensive list of what properties / functions/ methods are available and not available across platforms?
2. Is there a quick guide OR reference OR tool to help convert code to other platforms which can help me ? if not, then, is hit an trial the only way to navigate forward?

'called by

Sub FontAwesomeToBitmap (Text As String, FontSize As Float) As B4XBitmap
    Dim xui As XUI
    Dim p As Panel = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 32dip, 32dip)
    Dim cvs1 As B4XCanvas
    Dim fnt As B4XFont = xui.CreateFontAwesome(FontSize)
    Dim r As B4XRect = cvs1.MeasureText(Text, fnt)
    Dim BaseLine As Int = cvs1.TargetRect.CenterY - r.Height / 2 - r.Top
    cvs1.DrawText(Text, cvs1.TargetRect.CenterX, BaseLine, fnt, PressedColor, "CENTER")
    Dim b As B4XBitmap = cvs1.CreateBitmap
    Return b
End Sub


Licensed User
Longtime User
As written: ... which can be almost the same...
This means that there are differences between the platforms.

The only advice: use as much as possible B4XViews, these are wrappers above the platform specific objects with cross-platform common properties.
For more details you might have a look here:
In your example: instead of using a Label you may use a B4XView using the new As property:
Or, the line above is the short way of the code below:
Private xLabel1 As B4XView
xLabel1 = Label1

You may have a look at the B4X Help Viewer which allows to display all properties, events and methods for all B4X objects.
You can select a platform, a library, an object, a method / event / property and display its functionality.
Upvote 0


Active Member
Licensed User
Thanks @klaus
It is nice to have seasoned developers like you around here, ready to help and guide.
I'm yet to get my head around .as and as and .asview and casting.
Will surely check b4x help viewer !!! šŸ‘
Upvote 0