B4A Library BottomSheetBuilder

I have started building a new library similar to ParsBottomSheetBuilder https://www.b4x.com/android/forum/threads/parsbottomsheetbuilder.105081/ because it is not compatible with Android SDK 34.
Requirements: RippleDrawable Library https://www.b4x.com/android/forum/threads/rippledrawable.77164/


All contributions and improvements are welcome :)


VideodeWhatsApp2024-08-17alas14.09.31_f81d5183-ezgif.com-resize (1).gif
 

Attachments

  • ParsBottomSheetBuilder.zip
    12.8 KB · Views: 47
Last edited:

TILogistic

Expert
Licensed User
Longtime User
use Ripple Effect for multi platform B4X
B4X:
'https://www.b4x.com/android/forum/threads/b4x-xui-simple-halo-animation.80267/#content
Private Sub RippleEffect (Parent As B4XView, Color As Int, Duration As Int)
    Dim cvs As B4XCanvas
    Dim p As B4XView = xui.CreatePanel("")
    Dim InnerRadius As Int = Parent.Height * 1.30
    If Parent.Width <> Parent.Height Then InnerRadius = Max(Parent.Width, Parent.Height) * 1.60
    p.SetLayoutAnimated(0, 0, 0, InnerRadius, InnerRadius)
    cvs.Initialize(p)
    cvs.DrawCircle(cvs.TargetRect.CenterX, cvs.TargetRect.CenterY, cvs.TargetRect.Width / 2, Color, True, 0)
    Dim bmp As B4XBitmap = cvs.CreateBitmap
    p.RemoveViewFromParent
    Dim iv As ImageView
    iv.Initialize("")
    Dim p As B4XView = iv
    Dim Radius As Int = InnerRadius/2
    Dim x As Int = Parent.Width/2
    Dim y As Int = Parent.Height/2
    p.SetBitmap(bmp)
    Parent.AddView(p, x, y, 0, 0)
    p.SetLayoutAnimated(Duration, x - Radius, y - Radius, Radius * 2, Radius * 2)
    p.SetVisibleAnimated(Duration, False)
    Sleep(Duration)
    p.RemoveViewFromParent
End Sub

 

scsjc

Well-Known Member
Licensed User
Longtime User
I just updated the code because on screens with different resolutions and font sizes, it looked terrible.
Trying to understand how it works, I read some posts, but I still couldn't get it to work properly.

Finally, I created a rudimentary code (like something from the Stone Age, haha) that seems to work quite well and adapts to both tablets and mobile devices, even when the font size is changed.

Any suggestions or improvements are welcome :)


B4X:
Dim C As Canvas
    C.Initialize(vActivity)
    Dim x As String
    x = Round((c.MeasureStringHeight("X,_", Typeface.SANS_SERIF, 10)/10+0.15)/0.25)*0.25
    Log("x:" & X)
    If x <= 2.25  Then
        iconsize = 50dip
        textsize = 14
        limitestring = 11
    Else If x <= 2.50  Then
        iconsize = 45dip
        textsize = 13
        limitestring = 11
    Else If x <= 3  Then
        iconsize = 45dip
        textsize = 11
        limitestring = 11
    Else If x <= 3.25  Then
        iconsize = 40dip
        textsize = 10
        limitestring = 11
    Else If x <= 3.75  Then
        iconsize = 35dip
        textsize = 10
        limitestring = 10
    Else If x <= 4.25  Then
        iconsize = 32dip
        textsize = 9
        limitestring = 10
    Else If x <= 5.25  Then
        iconsize = 28dip
        textsize = 8
        limitestring = 9
    Else
        iconsize = 40dip
        textsize = 10
        limitestring = 11
    End If
 
Top