Android Question AVD Screen Size & Scale

fasilosman

Active Member
Licensed User
Longtime User
Can any one help me to create different screen sized in different scaled emulators /avd in the new AVD manager to test the custom listview as I attached.

I found only few emulator screen sized and two scale options. How can I create the new AVD as I wanted.
 

Attachments

  • Screenshot_1543079778.png
    Screenshot_1543079778.png
    10.9 KB · Views: 578
  • Screenshot_1543079914.png
    Screenshot_1543079914.png
    9.1 KB · Views: 496
Last edited:

fasilosman

Active Member
Licensed User
Longtime User
There are three screen sizes in B4A AVD Manager. Scale isn't really important if you correctly use 'dip' values.

.

I got your point. But Still I face the problem with fonts size. In 4 inch 1.5 scale emulator font size is much bigger and unable to show all text within the label. Do I have to use any screen resolution formula to reduce the font size. If so give me an example please.
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
Sounds like you did a mistake. Make sure NOT to use dip units with font sizes.
I Didn't use dip in font size. I set "AutoScaleAll" in designer and to view I used dip instead of %. But for the font sized I didn't change anything. Is there anyway to reduce it according to the screen resolution.
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
1. Please post a screenshot of the layout.

2. Upload a small project with the layout.

Is this screen shoot enough to understand. or do I need to create a small project.
 

Attachments

  • 4inch AVD.png
    4inch AVD.png
    148.8 KB · Views: 508
  • 6Inch AVD.png
    6Inch AVD.png
    139.7 KB · Views: 515
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The font size is not really larger. It just looks like this in the emulator. The issue you are seeing is not related to the scale. It is related to the label size not being large enough.

AutoScaleAll can help here if used correctly. It will help if you have a single variant set based on the small screen size (320x480, scale = 1).
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
AutoScaleAll can help here if used correctly. It will help if you have a single variant set based on the small screen size (320x480, scale = 1).

Yes. I used "AutoScaleAll" in my all designer scripts as default and all designers layouts are designed based with "variant 320x480, scale = 1". If you think this problem is only in AVD and it will be ok in real devices then its fine.
 
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
If you think this problem is only in AVD and it will be ok in real devices then its fine
I don't think so. What I meant to say is that the font is not really larger it just looks like this in the emulator. However the issue itself is real. You should make the labels larger or reduce the font size. You can also test it with the UI cloud.
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
@fasilosman

Just as a matter of interest (and possibly I'm going off my head) - did you edit your post - I seem to recall that your original post said you were having a problem with your Samsung Galaxy J5 ?
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
@fasilosman

Just as a matter of interest (and possibly I'm going off my head) - did you edit your post - I seem to recall that your original post said you were having a problem with your Samsung Galaxy J5 ?

Yes. Then I have been went through several testing and finally I came to this point. But I don't have a device to test it other than the emulator. That why I asked , how to create a customized AVD"
Any way thanks for your consideration.
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
I don't think so. What I meant to say is that the font is not really larger it just looks like this in the emulator. However the issue itself is real. You should make the labels larger or reduce the font size. You can also test it with the UI cloud.

01. The 6 inch AVD looks ok. But 4 inch AVD has the problem. If I reduce the font size then, it looks too small in 6 inch AVD.

02. It is a custom view. I loaded the layout into a panel , then I added the panel into the scroll view. Therefore , I think it can be tested in runtime only and I am unable to test it in Abstract designer or UI cloud. Do you have any other way to test it.
 
Last edited:
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
Ok - here is a long reply. Maybe it will help you. (NB - All code below comes from various contributors on this forum - thanks to all !!)

I have just been through this exercise (and almost lost a contract and been accused of not having the skills to put a "professional" product on the market).

I have 3 device (all Samsungs - my development device being a Galaxy S8+) on which I do most of my work. I designed all my screens (all 77 of them) on this device and everything worked perfectly and looked spectacular. Then came the crunch - one of my clients with exactly the same device reported that none of my screens were fitting on his device. Now this sounds impossible - but after some screen shots - it was confirmed true.

See Correct Screen below - this is how it was intended
Correct Screen.jpg
and Faulty Screen is how it appeared on the other similar device (S8+).
Faulty Screen.jpg or this Error Large Font.PNG

I had done all correctly and according to accepted standards (anchors, variants etc) but still no joy, then by accident I found out that SAMSUNG have a place where you can set screen sizes and font sizes and fonts on their Galaxies running Android 8.0 (not sure if this was available before), effectively giving a combination of 27 different settings on one device. On further investigation I found that this was the culprit and was causing all the pain and now listed below is how I found this and corrected it with a method, which is probably not the way to do things - but it works for me. Below is how you change the font settings etc on a Samsung running Android 8
Samsung Settings.jpg

After checking on my S8+ with all screen sizes in the IDE, I got 3 different variants from the 3 different settings, These were:
411 x 797 x 1
360 x 692 x 1
320 x 609 x 1
and they should adjust perfectly with anchors (which they do - provided....) but the problem comes now with the font settings. You have 7 Font sizes and 5 default fonts (remember a thing called kerning ?) which will give you an effective 35 different permutations AND you cannot dictate to your customer which setting to use !!

So how did I solve this or do a work around ?

1. I went to every screen design and put in a derivative of 360 x 692 x 1 AND deleted all the others.
2. I then created a spreadsheet as in the figure below:
Spreadsheet.PNG

3. Now I went to my Designer (and this is a bit of donkey work) and changed each item in my screen design to accept percentages (which I got from the spreadsheet) - something like this
Percentage Script.PNG

4. Once this was complete (and I now know that my design will fit any screen size now), I then turned to my app and did the following to take care of the Font size issue:

In the Main Module I ticked the Accessibility Library

Secondly I did this
B4X:
Sub Process_Globals
       Public access As Accessiblity
End Sub

and then this:

B4X:
Sub ResetUserFontScale(p As Panel)
    For Each v As View In p
        If v Is Panel Then
            ResetUserFontScale(v)
        Else If v Is Label Then
            Dim lbl As Label = v
            lbl.TextSize = lbl.TextSize / access.GetUserFontScale
        Else If v Is Spinner Then
            Dim s As Spinner = v
            s.TextSize = s.TextSize / access.GetUserFontScale
        Else If v  is Button Then
            Dim b as Button = v
            b.TextSize = b.TextSize / access.GetUserFontScale
        End If
    Next
End Sub

and called it from Activity_Create like this

B4X:
Sub Activity_Create(FirstTime As Boolean)
       ResetUserFontScale(Activity)
End Sub

and in some places I just did this:

B4X:
       editText.TextSize = editText.TextSize / access.GetUserFontScale
       ' and to call it from other modules use
        editText.TextSize = editText.TextSize / Main.access.GetUserFontScale

I also checked and changed several places with items as listed below:

B4X:
    Private ExpandedHeight As Int = 23.1%y
    Private CollapsedHeight As Int = 11.6%y
    'or this
    pnlFavourite.SetLayoutAnimated(1000, 8.35%x, 58%y, 83.3%x, 31.8%y) 'as required

This might seem like a long drawn out process, but I know now that it fits on any screen derivative and all the fonts are perfect every time as designed, especially the problem you have had with loading a layout into a Custom List (one of my biggest headaches) amongst others.

Remember, when testing - first set your device to one size - test, then the next size, test etc - the only way to make sure and actually have 3 devices in your hand.

And as @Peter Simpson would say:

Enjoy dot dot dot :p

Anything you are unsure of or that is not clear - please ask.
 
Upvote 0

fasilosman

Active Member
Licensed User
Longtime User
This might seem like a long drawn out process, but I know now that it fits on any screen derivative and all the fonts are perfect every time as designed, especially the problem you have had with loading a layout into a Custom List (one of my biggest headaches) amongst others.

Remember, when testing - first set your device to one size - test, then the next size, test etc - the only way to make sure and actually have 3 devices in your hand.

And as @Peter Simpson would say:

Enjoy dot dot dot :p

Anything you are unsure of or that is not clear - please ask.


Mind blowing. Finally you became the professional killer. Since I am a beginner you gave an interesting path to correct the issue. "Font is the biggest problem in custom views. Just now only I know this command "GetUserFontScale". Thank a lot for the great support. I think you may post as a tutorial then it would help other developers too. :)
 
Upvote 0
Top