Android Question Can Basic for Android help me

oliverm

Member
Licensed User
Longtime User
Hi

I want to make a text based app, but I want to avoid the Visual Basic, form style, look of many B4A apps and stick with a really simple but lush Holo design, with subtle fades in and out and a thin san serif font.

You can see the effect I'm after in the app "Oblique Strategies" by Shaun Church in the Google Play store. I've attached a screenshot but you have to see the fades and the like to see what I mean.

Is this something B4A can help with in the latest version? The last time I looked at B4A, which was v2.2, it wasn't great at the visual styles set down by Google and appeared much more suitable for functional apps.

Olly
 

Attachments

  • Screenshot_2014-09-28-14-38-02.png
    Screenshot_2014-09-28-14-38-02.png
    72.2 KB · Views: 141

DonManfred

Expert
Licensed User
Longtime User
you have to see the fades and the like to see what I mean.

Is this something B4A can help with in the latest version? The last time I looked at B4A, which was v2.2, it wasn't great at the visual styles set down by Google and appeared much more suitable for functional apps.

There is no native control in b4a to do such fades... BUT it isn´t hard to do it by yourself...

I have made a quick and dirty one... See Attached Example

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private lblInfo As Label
    Private collist As List
    Private txtlist As List
    Private destcol(4),actcol(4), white(4) As Int
    Private tmr,tmrfont As Timer
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("main")
    tmr.Initialize("ColChange",20)
    tmrfont.Initialize("FontChange",10)
    collist.Initialize
    collist.Add(Colors.RGB(100,200,220))
    collist.Add(Colors.RGB(180,52,72))
    collist.Add(Colors.RGB(135,160,220))
    collist.Add(Colors.RGB(205,220,240))
    collist.Add(Colors.RGB(200,180,160))
   
    txtlist.Initialize
    txtlist.Add("This is a long testtext to check the labels dimensions...")
    txtlist.Add("The quick brown fox jumps over the lazy dog...")
    txtlist.Add("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.")
    lblInfo.Typeface = Typeface.LoadFromAssets("roboto-light.ttf")
    lblInfo.TextColor = Colors.white
    lblInfo.TextSize = 30
    lblInfo.Text = "This is a long testtext to check the labels dimensions..."

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub GetARGB(Color As Int) As Int()
    Dim res(4) As Int
    res(0) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff000000), 24)
    res(1) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff0000), 16)
    res(2) = Bit.UnsignedShiftRight(Bit.AND(Color, 0xff00), 8)
    res(3) = Bit.AND(Color, 0xff)
    Return res
End Sub

Sub lblInfo_Click
    actcol(1)=destcol(1)
    actcol(2)=destcol(2)
    actcol(2)=destcol(3)
    Dim random As Int = Rnd(0,collist.Size)
  destcol = GetARGB(collist.Get(random))
    destcol(0)=255   
    lblInfo.Color = Colors.ARGB(255,destcol(1),destcol(2),destcol(3))
    lblInfo.TextColor = Colors.white
    white = GetARGB(Colors.White)
    white(0) = 255

    Dim random As Int = Rnd(0,txtlist.Size)
    lblInfo.Text = txtlist.Get(random)
   
    tmr.Enabled = True
    'lblInfo.TextColor
End Sub
Sub FontChange_Tick
    If white(0) > 0 Then
        white(0) = white(0)-1
    End If
    lblInfo.TextColor = Colors.ARGB(white(0),white(1),white(2),white(3))
    If white(0) = 0 Then
        tmrfont.Enabled = False
        Log("Font opaque... Set new Text and start again...")
    End If
End Sub
Sub ColChange_Tick
    Dim r,g,b As Boolean = False
   
    If actcol(1) > destcol(1) Then
        ' Decrease R
        actcol(1) = actcol(1)-1
    Else If actcol(1) < destcol(1) Then
        ' Increase R
        actcol(1) = actcol(1)+1
    Else If actcol(1) = destcol(1) Then
        ' R reached destination
        r = True
    End If
    If actcol(2) > destcol(2) Then
        ' Decrease G
        actcol(2) = actcol(2)-1
    Else If actcol(2) < destcol(2) Then
        ' Increase G
        actcol(2) = actcol(2)+1
    Else If actcol(2) = destcol(2) Then
        ' G reached destination
        g = True
    End If
    If actcol(3) > destcol(3) Then
        ' Decrease B
        actcol(3) = actcol(3)-1
    Else If actcol(3) < destcol(3) Then
        ' Increase B
        actcol(3) = actcol(3)+1
    Else If actcol(3) = destcol(3) Then
        ' B reached destination
        b = True
    End If
    lblInfo.Color = Colors.ARGB(255,actcol(1),actcol(2),actcol(3))
    If r Then
        If g Then
            If b Then
                Log("Destinationcolor reached")
                tmr.Enabled = False
                tmrfont.Enabled = True
            Else
                'Log("SetColor("&actcol(1)&","&actcol(2)&","&actcol(3)&")")
            End If
        Else
            'Log("SetColor("&actcol(1)&","&actcol(2)&","&actcol(3)&")")
        End If
    Else
        'Log("SetColor("&actcol(1)&","&actcol(2)&","&actcol(3)&")")
    End If
End Sub
 

Attachments

  • obliqueremake.zip
    80.7 KB · Views: 123
Upvote 0

oliverm

Member
Licensed User
Longtime User
Thanks Manfred.

That's really useful. I've changed the lineheight and tweaked the font and it's all very workable.

One thing though, I can't see to change the fade time that much. I guess this might be a limitation caused by B4A not supporting fades natively. I've reduced the timer interval, which helps but not significantly. I've also increased the value by which the RGB counters increase, so it jumps through the colour scale faster. However this changes the nature of the fade and causes 'leaping' as it jumps from colour to colour.

Ideally I'd like the fade to take <2 sec so it's a subtle change in colours.

Might it be possible to use a reflector to handle the fade or would that be massively too complex?

Olly
 
Upvote 0
Top