Android Question Theme Effect & Visibility

iCAB

Well-Known Member
Licensed User
Longtime User
Hi There

I encountered an interesting problem and I am wondering if any one can provide an explanation.

The code I am attaching, displays a popup similar to a spinner.

If the manifest file contains the line below, then all is fine
B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")

if I comment out the above and replace with the line below, then the scrollview goes behind btnBackground and therefore it is not visible
B4X:
CreateResourceFromFile(Macro, Themes.LightTheme)

Please check the note in the middle of the code to duplicate the issue.
I am providing the code in here
B4X:
Private Sub AddSpinner()
    
    Dim dblNextTop As Double
    
    PopupPanel.Initialize("ScrollView")
    PopupPanel.Color = Colors.ARGB( 121, 0, 0, 0 )
    PopupPanel.Elevation = 20dip
    pnlMain.AddView( PopupPanel, 0, 0, 100%x, 100%y)
    
    Dim lbl As Label
    lbl.Initialize("")
    lbl.Color = Colors.RGB(250,250,250)
    lbl.Text = "Title"
    lbl.TextColor = Colors.Black
    lbl.TextSize = 18
    lbl.Gravity = Gravity.CENTER
    lbl.Typeface = Typeface.DEFAULT_BOLD
    
    PopupPanel.AddView( lbl, 10%x, 20%y, 80%X, 8%y)
    dblNextTop = lbl.Top + lbl.Height
    
    Dim btnBackground As Button
    btnBackground.Initialize ("")
    btnBackground.Tag = "btnBackground"
    btnBackground.Color = Colors.Gray   
    PopupPanel.AddView( btnBackground, 10%x, dblNextTop, 80%x, 30%y)

        '*********** How to duplicate the issue
        '**** if Visible = true and SetApplicationAttribute(android:theme, "@android:style/Theme.Holo") then no problem
        '**** if Visible = true and CreateResourceFromFile(Macro, Themes.LightTheme), then scrollview doesn't move in front of the button, I tried sendtoback doesn't make a difference
    btnBackground.Visible = True
    
    Dim svSpinnerPanel As ScrollView
    svSpinnerPanel.Initialize2(30%y, "svSpinnerPanel")
    svSpinnerPanel.Panel.Height = 0
    
    PopupPanel.AddView( svSpinnerPanel, 10%x, dblNextTop, 80%x, 30%y)
    
    Dim PanelColors(4) As Long = Array As Long ( Colors.blue, Colors.Green, Colors.Red, Colors.Yellow)
    For iPanelIndex  = 0 To 3
        
        
        Dim pp1 As Panel
        pp1.Initialize("Permission" )
        pp1.Tag = "pnl_" & iPanelIndex
        pp1.Color = PanelColors( iPanelIndex)
        svSpinnerPanel.Panel.AddView(pp1, 0, iPanelIndex  * svSpinnerPanel.Height/4, 100%x, svSpinnerPanel.Height/4) 
        pp1.BringToFront
        
        svSpinnerPanel.Panel.Height = svSpinnerPanel.Panel.Height + svSpinnerPanel.Height/4
        
'        AddSpinnerPanelToScrollView( svSpinnerPanel, iPanelIndex )
    Next
    
    svSpinnerPanel.Panel.Height = svSpinnerPanel.Panel.Height + 10%y

    
    dblNextTop = btnBackground.Top + btnBackground.Height

    Dim btnDone As Button
    btnDone.Initialize ("btnDone")
    btnDone.Tag = "btnDone"
    PopupPanel.AddView( btnDone, 10%x, dblNextTop, 80%x, 10%y)
    btnDone.Color = Colors.White
    btnDone.Enabled = True
    btnDone.Text = "Done"
    btnDone.TextColor = Colors.Green
    btnDone.BringToFront
    
    
End Sub


Private Sub btnDone_Click
    PopupPanel.RemoveAllViews
    PopupPanel.RemoveView
End Sub

Thanks in advance.
iCAB
 

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Erel,

Thanks for your reply

1. Never use the holo theme.
I don't want to use the holo theme, but the problem was triggered by me removing the holo theme from an old project

2. I don't see any problem with the code and it displays the custom popup properly for B4A(holo theme) and B4I

3. btnBackground, in theory shouldn't block the scrollview, so why is it? Is there an explanation?

4. I am moving gradually to B4XDialogs. I have few questions about custom views but I'll open a separate ticket later on.

I am attaching a sample project. Please run it and see what I am talking about.


Thanks
iCAB
 

Attachments

  • ThemeEffectTest.zip
    10.4 KB · Views: 74
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Sorry I forgot to mention that I changed the code before replying

B4X:
        Dim pp1 As Panel
        pp1.Initialize("Permission" )
        pp1.Tag = "pnl_" & iPanelIndex
        pp1.Color = PanelColors( iPanelIndex)
        svSpinnerPanel.Panel.AddView(pp1, 0, iPanelIndex  * svSpinnerPanel.Height/4, 100%x, svSpinnerPanel.Height/4) 
        pp1.Elevation = 20dip
        pp1.BringToFront

and I also tried

B4X:
svSpinnerPanel.Panel.Elevation = 3dip

but I am still getting the same results.

Thanks
iCAB
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Erel,

I have attached a sample project to duplicate the problem in post #3.

As I mentioned I tried setting the elevation for the scroll view base panel as well as for the panels being added to the scroll view.

So I am not sure which part you are saying is wrong.

Thanks
iCAB
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
There are many bad practices in this code.
As I mentioned this is simply a test code that I put together to duplicate a problem that I faced after removing the "holo theme".

Just for my own info, where is the bad practice that you see in the code, other than having the button behind the spinner?

Thanks
iCAB
 
Upvote 0

Star-Dust

Expert
Licensed User
As I mentioned this is simply a test code that I put together to duplicate a problem that I faced after removing the "holo theme".

Just for my own info, where is the bad practice that you see in the code, other than having the button behind the spinner?

Thanks
iCAB
Without Holo, as Erel has already explained, the btnBackground button is high and covers ScrollView.

Put the button inside a panel and you won't have the problem. However, in fact, the example seems very confusing.

in AddSpinner....
B4X:
Dim btnBackground As Button
btnBackground.Initialize ("")
btnBackground.Tag = "btnBackground"
btnBackground.Color = Colors.Gray 
  
Dim P2 As Panel
P2.Initialize("")
PopupPanel.AddView( P2, 10%x, dblNextTop, 80%x, 30%y)
P2.AddView(btnBackground,0,0,P2.Width,P2.Height)
 
Last edited:
Upvote 0
Top