Android Question AVD Screen Size & Scale

Discussion in 'Android Questions' started by fasilosman, Nov 24, 2018.

  1. fasilosman

    fasilosman Active Member Licensed 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.

    Attached Files:

    Last edited: Nov 25, 2018
  2. Erel

    Erel Administrator Staff Member Licensed User

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

    If your custom view looks properly in 4'', 6'' and 10'' devices then it will look properly on all devices.
  3. fasilosman

    fasilosman Active Member Licensed User

    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.
    BillMeyer likes this.
  4. Erel

    Erel Administrator Staff Member Licensed User

    Sounds like you did a mistake. Make sure NOT to use dip units with font sizes.
  5. fasilosman

    fasilosman Active Member Licensed User

    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.
    BillMeyer likes this.
  6. Erel

    Erel Administrator Staff Member Licensed User

    1. Please post a screenshot of the layout.

    2. Upload a small project with the layout.
  7. fasilosman

    fasilosman Active Member Licensed User

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

    Attached Files:

  8. Erel

    Erel Administrator Staff Member Licensed 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).
  9. fasilosman

    fasilosman Active Member Licensed User

    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: Nov 25, 2018
  10. Erel

    Erel Administrator Staff Member Licensed 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.
    Peter Simpson and BillMeyer like this.
  11. BillMeyer

    BillMeyer Well-Known Member Licensed User


    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 ?
  12. fasilosman

    fasilosman Active Member Licensed User

    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.
  13. fasilosman

    fasilosman Active Member Licensed User

    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: Nov 25, 2018
  14. BillMeyer

    BillMeyer Well-Known Member Licensed 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:
    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
    Sub Process_Globals
    Public access As Accessiblity
    End Sub
    and then this:

    Sub ResetUserFontScale(p As Panel)
    For Each v As View In p
    If v Is Panel Then
    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
    End Sub
    and called it from Activity_Create like this

    Sub Activity_Create(FirstTime As Boolean)
    End Sub
    and in some places I just did this:

    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:

    Private ExpandedHeight As Int = 23.1%y
    Private CollapsedHeight As Int = 11.6%y
    'or this
        pnlFavourite.SetLayoutAnimated(10008.35%x58%y83.3%x31.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.
  15. fasilosman

    fasilosman Active Member Licensed User

    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. :)
    BillMeyer likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice