Android Question Transparent panel

fishwolf

Well-Known Member
Licensed User
Longtime User
I have modify card example.
Is it possible set a total and percentage trasparent on panel?

Screenshot.jpg
 

Attachments

  • Main.zip
    97.7 KB · Views: 57

Sagenut

Expert
Licensed User
Longtime User
In the layout Designer modify the Alpha of the color of the panel.
255 is solid color, 0 is totally transparent.
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
I have modify card example.
Is it possible set a total and percentage trasparent on panel?

View attachment 144028
Use
example:
B4X:
Private Sub CreateCard(Width As Int, Title As String, Image As String, Content As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    SetAlpha(p, 0.3)

B4X:
'Level between 0 (transparent) to 1 (opaque)
Public Sub SetAlpha (View As B4XView, Level As Float)
    #if B4A
    Dim jo As JavaObject = View
    Dim alpha As Float = Level
    jo.RunMethod("setAlpha", Array(alpha))
    #Else If B4J
    Dim n As Node = View
    n.Alpha = Level
    #else if B4i
    Dim v As View = View
    v.Alpha = Level
    #End If
End Sub

See:
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
Use
example:
B4X:
Private Sub CreateCard(Width As Int, Title As String, Image As String, Content As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    SetAlpha(p, 0.3)

B4X:
'Level between 0 (transparent) to 1 (opaque)
Public Sub SetAlpha (View As B4XView, Level As Float)
    #if B4A
    Dim jo As JavaObject = View
    Dim alpha As Float = Level
    jo.RunMethod("setAlpha", Array(alpha))
    #Else If B4J
    Dim n As Node = View
    n.Alpha = Level
    #else if B4i
    Dim v As View = View
    v.Alpha = Level
    #End If
End Sub

See:
With this code i have OTTENUTO.jpg:

i would have this effect Desiderato.jpg:

Similar to this

can i have a complete example?

Thanks
 

Attachments

  • OTTENUTO1.jpg
    OTTENUTO1.jpg
    266.6 KB · Views: 61
  • Desiderato.jpg
    Desiderato.jpg
    83.8 KB · Views: 56
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
by code and with shadow
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim ColorSelected, ColorUnselected As ColorDrawable
   
    Private CLV1 As CustomListView
    Private ImageFlower As B4XView
    Private LabelTitle As B4XView
    Private LabelBody As B4XView
    Private LabelAction As B4XView

    Private Panel1 As B4XView
End Sub

EDIT
B4X:
    CLV1.GetBase.SetBitmap(xui.LoadBitmapResize(File.DirAssets, "cardimage1.jpeg", CLV1.GetBase.Width, CLV1.GetBase.Height, False))
    
    CLV1.sv.ScrollViewInnerPanel.Color = xui.Color_Transparent 'color divisor

    CLV1.Add(CreateCard(CLV1.AsView.Width, $"AAA"$, bitmaps.Get(0), content), "")

B4X:
Private Sub CreateCard(Width As Int, Title As String, Image As String, Content As String) As Panel
    Dim p As B4XView = xui.CreatePanel("")
   
    Dim height As Int = 280dip
    If GetDeviceLayoutValues.ApproximateScreenSize < 4.5 Then
        height = 310dip
    End If
   
    'height = 200dip
    p.SetLayoutAnimated(0, 0, 0, Width, height)
    p.LoadLayout("Card")
    Panel1.SetColorAndBorder(0x7EF0FFFF, 1dip, 0x7EF0FFFF, 8dip)
    SetShadow(Panel1, 8dip, 0x7EF0FFFF)

1690716365431.png
 
Last edited:
Upvote 0
Top