Android Question [Solved] Problem with Admob-Height

Filippo

Expert
Licensed User
Hi,

this code does not work properly on my Nokia 7.1, because the banner is cut off (see pictures).
So that it is correctly displayed correctly on the Nokia, I have to change the height to 90dip, is this normal?

B4X:
Adview1.Initialize2("Ad", "xxxxxxxx", AdView1.SIZE_SMART_BANNER)
Dim height As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
       'phones
       If 100%x > 100%y Then height = 32dip Else height = 50dip
   Else
       'tablets
       height = 90dip
   End If
   Activity.AddView(AdView1, 0dip, 100%y - (toolbar.height + height), 100%x, height)
Correct presentation at HTC-one.
b4a_01.png


Wrong presentation on Nokia 7.1
b4a_02.png

 

asales

Well-Known Member
Licensed User
Did you have the same behavior using AdView.SIZE_BANNER instead of SMART_BANNER?
 

Filippo

Expert
Licensed User
Did you have the same behavior using AdView.SIZE_BANNER instead of SMART_BANNER?
With "AdView.SIZE_BANNER" the height is correct, but the width is too small.
 

Filippo

Expert
Licensed User

LucaMs

Expert
Licensed User
I searched the screen sizes:

Nokia 7.1 - 5.84"

HTC One - 4.7"

1) so the banner height seems wrong on the HTC
1) log(GetDeviceLayoutValues.ApproximateScreenSize)
3) the position of the banner seems wrong to me; it appears to be positioned lower down.
 

Filippo

Expert
Licensed User
Here's the output of this routine on Samsung A5(2017) and Nokia 7.1.
B4X:
Sub GetAddViewHeight As Int
    Dim height As Int
    If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
       'phones
        If 100%x > 100%y Then height = 32dip Else height = 50dip
    Else
        If 100%y > 100%x Then
               'tablets
               height = 90dip
        Else
            height = 50dip
        End If
    End If
    Log("AddViewHeight=" & height)
    Return height
End Sub
Samsung A5(2017):
AddViewHeight=150
Nokia 7.1:
AddViewHeight=131
For Nokia, the Adview height should be higher than the Samsung, because the display height of the Nokia is higher than that of the Samsung.
Nokia-Diplay: 1.080 x 2.280 Pixel
Samsung-Display: 1.080 x 1.920 Pixel
 

LucaMs

Expert
Licensed User
1920 / 2280 = 0.8421

131 / 150 = 0.8733

the difference is insignificant, the two banners have the same height, I think.
Check the top bottom position.
 

Filippo

Expert
Licensed User
1920 / 2280 = 0.8421

131 / 150 = 0.8733

the difference is insignificant, the two banners have the same height, I think.
Check the top bottom position.
Ciao Mario,

I've already tried that, read my first post.
It has nothing to do with the position.
So that it is correctly displayed correctly on the Nokia, I have to change the height to 90dip, is this normal?
 

Filippo

Expert
Licensed User
Here with shifted position.

upload_2019-6-10_11-12-56.png
 

LucaMs

Expert
Licensed User
So that it is correctly displayed correctly on the Nokia, I have to change the height to 90dip, is this normal?
Both displays are less than 6", so...
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
so to get the same height you should change the height to 50dip rather than 90dip. Anyway, I still think they have the same height, 50dip
 

Filippo

Expert
Licensed User
Anyway, I still think they have the same height, 50dip
Should have the same height, but is not so. You can see it in this issue.
Code:
Sub GetAddViewHeight As Int
Dim height As Int
If GetDeviceLayoutValues.ApproximateScreenSize < 6 Then
'phones
If 100%x > 100%y Then height = 32dip Else height = 50dip
Else
If 100%y > 100%x Then
'tablets
height = 90dip
Else
height = 50dip
End If
End If
Log("AddViewHeight=" & height)
Return height
End Sub
Samsung A5(2017):
AddViewHeight=150
Nokia 7.1:
AddViewHeight=131
 

Filippo

Expert
Licensed User

sorex

Expert
Licensed User
that's the negative part of banners that they always consume space unless you hide and show them at certain points (game over screen in a game)
 

Filippo

Expert
Licensed User
Hi,
I have to open this post again, because the problem is not resolved yet.
In this photo are 2 smartphones where you can see that the height of the banner is right and the other is not.
How can you solve the problem?
20190803_122800.jpg
 

Filippo

Expert
Licensed User
https://www.b4x.com/android/forum/threads/layout-with-banner.86641/

Poi magari nel forum italiano ci dici quale sia il gioco... spero non il mio :D
unfortunately this does not solve my problem.
I noticed though that in Nokia you have to enlarge the banner to 90dip to be corrected.
But this cannot be the solution.

Poi magari nel forum italiano ci dici quale sia il gioco... spero non il mio :D
Si tratta del mio unico gioco di carte Solitario. :p
This is my only Solitaire card game.
 

LucaMs

Expert
Licensed User
unfortunately this does not solve my problem.
It works well for me. I use a panel as base, set its top and height based on the height of the banner (which depends on the device) and then load the layout into this base panel.
 
Top