Android Question Canvas Letters Appear Different on Different Devices

Guardian17

Active Member
Licensed User
Longtime User
I am trying to generate a background theme for a word game. Random letters are placed at somewhat random positions and orientations across a background Canvas. I want the theme background to be different each time the game is played. The code is below.

The problem I am having is that on my GalaxyS3 smartphone (running Android 4.1.2), the letters appear wholly-formed and filled-in (which is what I want), but on my Nexus10 tablet (running Android 4.4.2), only the outlines of the letters are visible with no fill. The exact same APK file is being run in debug mode on both devices (using the B4A Bridge).

Is there some "fill" parameter or specification I am missing? Is the problem related to the Android operating system version, or is it specific to the Nexus device?

B4X:
#Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: TestTheme
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: Landscape
    #CanInstallToExternalStorage: False
#End Region

Sub Process_Globals
End Sub

Sub Globals
    Dim Canvas1 As Canvas
    'theme background variables
    Dim ThemePanel As Panel
    Dim ThemeAlphaStr As String
    Dim Rand As Int
End Sub

#Region Project Attributes
    #ApplicationLabel: TestTheme
    #VersionCode: 1
    #VersionName:
    #SupportedOrientations: Landscape
    #CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes
    #FullScreen: False
    #IncludeTitle: False
#End Region

Sub Activity_Create(FirstTime As Boolean)
    ThemePanel.Initialize("")
    Activity.AddView(ThemePanel,0,0,100%x,100%y)
End Sub

Sub Activity_Resume
    DrawInitialBackground
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub DrawInitialBackground
    Canvas1.Initialize(ThemePanel)
    Dim strBkgndLetter As String
    Dim strTextColor, deltX, deltY As Int
    Dim strTop, strLeft, strTextSize, strDegree As Float
    Dim strRed, strGrn, strBlu As Int
    Dim strTypeface As Typeface
    Dim UpperXLim, UpperYLim As Int

    ThemeAlphaStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Canvas1.DrawColor(Colors.RGB( 0, 0, 0))
    UpperXLim = 12
    UpperYLim = 10

    For i = -1 To UpperXLim
        For j= -1 To UpperYLim
            Rand = Rnd(0,25)
            strRed = Rnd(80,255)
            strGrn = Rnd(80,255)
            strBlu = Rnd(80,255)
            strBkgndLetter = ThemeAlphaStr.SubString2(Rand,Rand+1)
            strTextSize = 80
            strTextColor = Colors.ARGB(60,strRed,strGrn,strBlu)
            deltX = Rnd(0,10)-5
            deltY = Rnd(0,10)-5
            Rand = Rnd(0,4)
            strTypeface = Typeface.DEFAULT
            strLeft = i*120 + deltX
            strTop = j*120 + deltY
            strDegree = Rnd(0,36)*10
                Canvas1.DrawTextRotated(strBkgndLetter, strLeft, strTop, strTypeface, _
                    strTextSize, strTextColor, "CENTER", strDegree)
        Next
    Next
    ThemePanel.Invalidate
End Sub
 

Guardian17

Active Member
Licensed User
Longtime User
Thanks, Steve! Copying the new core.jar file to my Libraries folder worked JUST FINE! Now the letters appear properly on my Nexus 10. :)
 
Upvote 0
Top