H HARRY Active Member Licensed User Longtime User Nov 5, 2016 #1 Hi, I have written quite some time ago a program for my Samsung Galaxy S4 mini with a screen of 960 * 540 and 256 dpi. I had never the intention to run this program on other devices, so there are no provisions for other screen sizes/properties. Now,this program still has to run on different phones, as other people are interested to have it. I have been looking on this site, but I am totally be overwhelmed by the possibilities and I don't now what to choose. Can somebody advice me on the most easy way make this program device independant, preferably with some example code. The program runs only in landscape mode. The Activity ( the ony one) is fairly simple; all views are on the Activity, no panels are involved. I use B4A 5.02 Thanks in advance, Harry Last edited: Nov 5, 2016
Hi, I have written quite some time ago a program for my Samsung Galaxy S4 mini with a screen of 960 * 540 and 256 dpi. I had never the intention to run this program on other devices, so there are no provisions for other screen sizes/properties. Now,this program still has to run on different phones, as other people are interested to have it. I have been looking on this site, but I am totally be overwhelmed by the possibilities and I don't now what to choose. Can somebody advice me on the most easy way make this program device independant, preferably with some example code. The program runs only in landscape mode. The Activity ( the ony one) is fairly simple; all views are on the Activity, no panels are involved. I use B4A 5.02 Thanks in advance, Harry
KMatle Expert Licensed User Longtime User Nov 5, 2016 #2 See here: https://www.b4x.com/android/forum/threads/supporting-multiple-screens-tips-and-best-practices.17647/ What I often do is just to place the views (if my app it tageting phones and there are just simple views) by %x and %y (so you know where they are - no matter how "big" the screen is - for me ot does not matter if it's 5, 6 or 7"). Then I adjust the textsizes Another one: Put all views on a scrollview (if you need more space for the views). Only on very small phones <5" this looks "crap". 99% Have devices >=5". So it's ok for me. On tablets use another layout (there is "more visible space" so you can arrange the views much nicer). Search the forum for other methods starting from the link above. Upvote 0
See here: https://www.b4x.com/android/forum/threads/supporting-multiple-screens-tips-and-best-practices.17647/ What I often do is just to place the views (if my app it tageting phones and there are just simple views) by %x and %y (so you know where they are - no matter how "big" the screen is - for me ot does not matter if it's 5, 6 or 7"). Then I adjust the textsizes Another one: Put all views on a scrollview (if you need more space for the views). Only on very small phones <5" this looks "crap". 99% Have devices >=5". So it's ok for me. On tablets use another layout (there is "more visible space" so you can arrange the views much nicer). Search the forum for other methods starting from the link above.
H HARRY Active Member Licensed User Longtime User Nov 6, 2016 #3 I am exercising now with AutoScaleRate and AutoScaleAll. The results are not what I expected. I am testing on my device (960 * 540 and 256 dpi) and a Samsung tablet with a screen width of 21.7 cm ( 1280*800 and 145 dpi?); unfortunately I do not have more phones. I have been playing with the AutoScaleRate: AutoScaleRate; Result on Tablet; Result on Phone 0.0: Tablet: 9,7 cm of width used; Phone: smaller usage than without AutoScaleAll 0.3: Tablet: 15 cm of width used; Phone: exactly as without AutoScaleAll 0.5: Tablet: 18 cm of width used; Phone: some views on right and bottom runs a little bit of screen 0.7: Tablet: complete screen used; Phone: some views on right and bottom run more of screen 1.0: Tablet: some views on right and bottom run of screen;Phone: some views on right and bottom run evenmore of screen So 0.3 is best for Phone and 0.7 is best for Tablet. The usage on tablet is not important; I just did it for testing. The real question is: when I stick to 0.3 will that be effective for other phones, with different size and dpi? Harry Upvote 0
I am exercising now with AutoScaleRate and AutoScaleAll. The results are not what I expected. I am testing on my device (960 * 540 and 256 dpi) and a Samsung tablet with a screen width of 21.7 cm ( 1280*800 and 145 dpi?); unfortunately I do not have more phones. I have been playing with the AutoScaleRate: AutoScaleRate; Result on Tablet; Result on Phone 0.0: Tablet: 9,7 cm of width used; Phone: smaller usage than without AutoScaleAll 0.3: Tablet: 15 cm of width used; Phone: exactly as without AutoScaleAll 0.5: Tablet: 18 cm of width used; Phone: some views on right and bottom runs a little bit of screen 0.7: Tablet: complete screen used; Phone: some views on right and bottom run more of screen 1.0: Tablet: some views on right and bottom run of screen;Phone: some views on right and bottom run evenmore of screen So 0.3 is best for Phone and 0.7 is best for Tablet. The usage on tablet is not important; I just did it for testing. The real question is: when I stick to 0.3 will that be effective for other phones, with different size and dpi? Harry
KMatle Expert Licensed User Longtime User Nov 6, 2016 #4 HARRY said: 0.0: Tablet: 9,7 cm of width used; Phone: smaller usage than without AutoScaleAll 0.3: Tablet: 15 cm of width used; Phone: exactly as without AutoScaleAll 0.5: Tablet: 18 cm of width used; Phone: some views on right and bottom runs a little bit of screen 0.7: Tablet: complete screen used; Phone: some views on right and bottom run more of screen 1.0: Tablet: some views on right and bottom run of screen;Phone: some views on right and bottom run evenmore of screen Click to expand... Browse the forum how to allign the views (anchors, etc.) but... That is the reason why I use %x and %y and add all the views by code. Example: Code: Copy UploadBTN.Initialize("Upload") UploadBTN.Text="Upload" AddImageBTN.Initialize("AddImage") AddImageBTN.Text="Add image" Activity.AddView(UploadBTN,0,90%y,50%x,10%y) Activity.AddView(AddImageBTN,51%x,90%y,49%x,10%y) The views are exactly where I want. On phones this is absolutely ok (my opinion). Never had issues. Upvote 0
HARRY said: 0.0: Tablet: 9,7 cm of width used; Phone: smaller usage than without AutoScaleAll 0.3: Tablet: 15 cm of width used; Phone: exactly as without AutoScaleAll 0.5: Tablet: 18 cm of width used; Phone: some views on right and bottom runs a little bit of screen 0.7: Tablet: complete screen used; Phone: some views on right and bottom run more of screen 1.0: Tablet: some views on right and bottom run of screen;Phone: some views on right and bottom run evenmore of screen Click to expand... Browse the forum how to allign the views (anchors, etc.) but... That is the reason why I use %x and %y and add all the views by code. Example: Code: Copy UploadBTN.Initialize("Upload") UploadBTN.Text="Upload" AddImageBTN.Initialize("AddImage") AddImageBTN.Text="Add image" Activity.AddView(UploadBTN,0,90%y,50%x,10%y) Activity.AddView(AddImageBTN,51%x,90%y,49%x,10%y) The views are exactly where I want. On phones this is absolutely ok (my opinion). Never had issues.
Erel B4X founder Staff member Licensed User Longtime User Nov 6, 2016 #5 AutoScaleAll slightly increases or decreases the views sizes. Out of the three designer features: anchors, designer script and autoscale, auto scale is the least important. Anchors are the most important and are very simple to use. Upvote 0
AutoScaleAll slightly increases or decreases the views sizes. Out of the three designer features: anchors, designer script and autoscale, auto scale is the least important. Anchors are the most important and are very simple to use.