Android Question add view to customview from designer

D

Deleted member 103

Guest
Hi,

I have a customview created (is only one panel) which you can add in the designer.
I now want to add from Disigner a view, is that possible? If yes, how?

B4X:
'Class module
Sub Class_Globals
    Private Modul As Object
    Private Event As String
    Private IsDesignerView As Boolean   
    Private pnlHolder, pnlBackground, pnlForeground As Panel
   
    Private distance As Int = 5dip
    Private shadow As Int = 2dip
    Private transparent, Gray, White As ColorDrawable
End Sub

'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Target As Object, EventName As String)
    Log("Initialize")

    transparent.Initialize(Colors.Transparent, 0)
    Gray.Initialize(Colors.Gray, 0)
    White.Initialize(Colors.White, 0)

    pnlHolder.Initialize("")
    pnlHolder.Background = transparent
   
    pnlBackground.Initialize("")
    pnlBackground.Background = Gray
   
    pnlForeground.Initialize("pnlForeground")
    pnlForeground.Background = White
   
    pnlHolder.AddView(pnlBackground, shadow, shadow, 100dip, 50dip)
    pnlHolder.AddView(pnlForeground, 0, 0, 95dip, 45dip)
End Sub

Public Sub DesignerCreateView(Base As Panel, Lbl As Label, props As Map)
    IsDesignerView = True
    Base.AddView(pnlHolder, 0, 0, Base.Width, Base.Height)
    Base.Background = transparent
   
    Log("DesignerCreateView")
    ResizeButton
End Sub

Private Sub ResizeButton
    Log("ResizeButton")
    pnlBackground.SetLayout(distance + shadow, distance + shadow, pnlHolder.Width - distance * 2, pnlHolder.Height - distance * 2)
    pnlForeground.SetLayout(distance, distance, pnlHolder.Width - distance * 2 - shadow, pnlHolder.Height - distance * 2 - shadow)
End Sub

Public Sub getVisible As Boolean
    Return pnlHolder.Visible
End Sub

Public Sub setVisible(Visible As Boolean)
    pnlHolder.Visible = Visible
End Sub
 
Top