Android Tutorial Supporting multiple screens - tips and best practices

Discussion in 'Tutorials & Examples' started by Erel, May 8, 2012.

Thread Status:
Not open for further replies.
  1. klaus

    klaus Expert Licensed User

    The reason why I multiply by ScaleX instead of ScaleY is depending on the heigt / width ratio, ScaleY can be bigger than ScaleX. If you mutiply by ScaleY you have the risc that the text doesn't fit anymore in the views width and you'll get two lines.
    But It should be lbl.TextSize = lbl.TextSize * Min(cScaleX, cScaleY).
    Replace in the Scale module line 211 by the line above.

    When you use SetReferenceLayout the ScaleRate is automatically set to 1.
     
  2. LucaMs

    LucaMs Expert Licensed User

    i'll try to modify line 211, ok, i understood, but you set lbl.TextSize in other subs too...
    perhaps it would be better to use a variable as cScaleTxt and initialize it in the same place of cScaleX, cScaleY ... ?

    P.S. I had forgotten that I have already done the test, using: cScaleX, cScaleY and (cScaleX cScaleY +) / 2 ... none of these is sufficient.

    setting min(...) is equal to select cScaleX or cScaleY
     
    Last edited: Nov 30, 2013
  3. klaus

    klaus Expert Licensed User

    Do have a screenshot that shows what is wrong.
     
  4. LucaMs

    LucaMs Expert Licensed User

    upload_2013-12-1_0-3-32.png

    upload_2013-12-1_0-3-52.png
     

    Attached Files:

    Last edited: Nov 30, 2013
  5. klaus

    klaus Expert Licensed User

    The default properties are different in emulators for different Android versions and also on different devices.
    Attached you find the result of an emulator on my computer for a 480_600_240_API10 which looks different than yours !?
    I also tested the TableV1_29 program like in your image on my Nexus One Android API 10 and on an API10 Emulator the default text size on the device is 14 and in the emulator it's 18 !?
    I can't take into acount these differences in the scaling routines.
     

    Attached Files:

  6. moster67

    moster67 Expert Licensed User

  7. klaus

    klaus Expert Licensed User

    Even if I knew the property value, I don't know what to do with it because I don't know what the developper nor the user really want.
    So for me it's up to the developper to take care of this.
     
  8. LucaMs

    LucaMs Expert Licensed User


    In your 480... textsize is better, but not perfect (bottom of "Aggiungi").

    However, since we have not found a solution ... I wonder how everyone else is doing, including big software house!

    I'm trying to adapt further in relation to the relationship lbl.textsize / lbl.Height (using various tricks).
    But I should know if the text is laid out on more than one line, in the view. Can you help me about this?

    But the strange thing is that it seems that it is only me to complain about this problem!
     
  9. moster67

    moster67 Expert Licensed User

    Klaus, by all means, my point was not meant for you. It was just, as you say, a suggestion for the developer to take into consideration since you with your module cannot cover it all.
     
  10. LucaMs

    LucaMs Expert Licensed User


    As a developer, I would "simply" this (resized image using IrfanViewer):
    upload_2013-12-1_13-13-28.png

    I do not want that B4A develops my app following my voice commands! (or maybe yes? :) )
     
  11. klaus

    klaus Expert Licensed User

  12. LucaMs

    LucaMs Expert Licensed User

    @moster67

    You wrote:
    "The other day I received a report (along with screenshots) from a user saying that certain labels on his Galaxy S3 were truncated or simply did not show up correctly. I found this rather odd since my developer-phone is also a Galaxy S3 and of course I had made sure that everything (my layouts) looked OK, not only on my S3, but also in other resolutions."

    I have not read the whole thread, but ...
    how you sized texts, in other resolutions? This is the question.
     
  13. moster67

    moster67 Expert Licensed User

    @LucaMs

    Everything is not "magic" - there is no universal formula in my opinion, especially with Android and all the resolutions available and great modules, such as the one by Klaus or the built-in script cannot cover them all.

    Many times I simply add specific layouts for different resolutions. Then with help of the UI-cloud offered by B4A, I test my layouts on different devices and I also take note which layout is being used (you can see that in the web-page generated by UI-cloud in B4A) and then I adapt my code/my specific layout.
     
  14. LucaMs

    LucaMs Expert Licensed User


    ... "manually"... ok, thanks.
     
  15. moster67

    moster67 Expert Licensed User

    Purtroppo sì - si deve smanettare un po'....

    That said, I am very pleased with the design-script and although I have not tried Klaus' module, I am sure it generates nice results as well, perhaps with even more flexibility. I think what generated by the design-scripts gives satisfactory results in at least 95% of the cases. When there is a discrepancy, I will make a specific layout.

    Remember that you can regenerate the layout by using activity.RerunDesignerScript, perhaps after obtaining some needed information by code regarding the device.

    Although I have not tried it but if you prefer the Android-way of building layouts using XML-files, I believe you can now also use Erel's XMLLayoutBuilder-library (http://www.basic4ppc.com/android/forum/threads/xmllayoutbuilder-load-xml-layouts.33762/). However, personally I prefer design-scripts which is a huge time-saver and gets good results in most cases.

    Just my 2 cents :)
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    I still don't understand why you want to create such a layout:

    [​IMG]

    The user expects to see more content in a tablet. There is no reason to create huge buttons, huge images and so on. The physical size of the text, buttons and the other views should be more or less similar. It doesn't matter if the user is holding a phone or a tablet.

    AutoScaleAll does help by slightly increasing the values for larger tablets.
     
  17. LucaMs

    LucaMs Expert Licensed User


    I understood only: "Purtroppo sì - si deve smanettare un po'...." (compliments :) )

    I will try to follow your advice.

    My main problem is laziness: I'm afraid I'll have to recreate my layouts (v.1.80) and also some suited to the various resolutions.

    The strange thing is that the difference Klaus pointed out: "same" emulator, etc..
    In addition, there is the problem Holo Light / Dark, and as usual, I read too quickly and not in my language, but i knew that regards the API 11.

    Moreover, "when" I'll have solved the graphics problems, I expect those of db data pseudo-synchronization and then export Mobile to PC.
    I'll announce the publication of my first app in 2025 ;)

    Thanks for your interest.

    Regards
     
  18. dexMilano

    dexMilano Active Member Licensed User

    Hello all,
    I've a stupid problem related to multiresolution application: having different icons of the launcher on different device.
    I want to have an icon 48x48 for 1.0 scaling and another for 1.5 scaling (it should be 72x72).
    In the Android iconography page it is described bu I don't know how to do with B4A.
    Thanks in advance.

    dex
     
  19. Erel

    Erel Administrator Staff Member Licensed User

  20. dexMilano

    dexMilano Active Member Licensed User

    As usual, Erel, your answer IS RIGHT!

    Thanks

    dex
     
Thread Status:
Not open for further replies.
Loading...
  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