Android Question Please help

Sanxion

Active Member
Licensed User
Longtime User
It is indicative of both a sign of desperation and testament to the generosity of this community that we can address the architect of this enviroment directly...therefore:

I have created a simple project to illustrate the problem I have been attempting to resolve for weeks...

The issue in summary: I have a series of labels surrounding a central label. In the Designer they are positioned for my development device and appear correctly when I test it. However, when I target any other device, the outer labels are moved out of position. What must I do to ensure they stay in the correct positions relative to the central label?

Here is a link to B4A UI Cloud output:

http://5.144.61.82:25613/?method=file&file=8757791729175284375.html

I have attached the project
 

Attachments

  • PositionTest.zip
    38.5 KB · Views: 143

ivan.tellez

Active Member
Licensed User
Longtime User
Please be shure to understand the basics of B4A before posting lots of basic questions.

You can start with the Documentation Index, the Tutorials List, the Beginner's Guide and the User's Guide

Listed on this page: https://www.b4x.com/b4a.html
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
Please be shure to understand the basics of B4A before posting lots of basic questions.

You can start with the Documentation Index, the Tutorials List, the Beginner's Guide and the User's Guide

Listed on this page: https://www.b4x.com/b4a.html

As I mentioned in my post "I have been attempting to resolve for weeks..."

I have been researching the problem myself to no avail and have been in contact with one particularly prominent member of this forum who suggested that I should present the issue here.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
have been in contact with one particularly prominent member of this forum

That´s weird, your proyect has no evidence of any attempt to resolve the problem.

As I said, this is very basic stuff covered on the documentation, please serarc for "variant script", you can position views with this.

Also search for using custom fonts, to mantain the same look across devices.


If you are using lots of labels, maybe your aproach is not the best. What if you draw directly instead of positioning lots of labels?
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
That´s weird, your proyect has no evidence of any attempt to resolve the problem.

As I said, this is very basic stuff covered on the documentation, please serarc for "variant script", you can position views with this.

Also search for using custom fonts, to mantain the same look across devices.


If you are using lots of labels, maybe your aproach is not the best. What if you draw directly instead of positioning lots of labels?

An absence of "evidence" does not indicate an absence of intent nor of action.

The basic project I have attached has "no evidence of any attempt to resolve the problem" as any attempt I have made so far has not worked. I thought it would be of little benefit to pollute the core issue with code and script that has not worked.

The labels are required as each one has an associated "on-click" event that causes the text to change.

Never-the-less, thank-you for your suggestions.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
The labels are required as each one has an associated "on-click" event that causes the text to change.

Thats not true.

You just need to know what is drawn where, and with a single click event you can determine what was clicked. Thats how games and other UIs work.


If you want to draw, maybe the Accelerated surface Lib could be usefull, if you whant labels, you can position in the "variant script" or directly in the code with the "SetLayout" method of the labesl.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Guys, before starting to throw "you should search before posting" lest try to remember two things:

We have ALL had this or a similar issue with our GUI, AND, keep the GUI looking "about the same" across different devices resolutions has always been the biggest challenge in Android dev.

This said, @Sanxion, Klaus has a B4X User's Begginers Guide, with entire chapters dedicated to the management of the GUI, you should check it out.
Also, as suggested, you don't need individual events for each label, as you can group related events into one single event and use the "sender" keyword to know wich label was clicked.
And I must ask, why use an external lib to accomplish something that is simple to achieve with core methods?

And again, @Sanxion, please note that this is and will continue to be an open forum, where each question is put to the whole community, and not only one member, even if it happens to be @Erel all mighty! He himself usually often makes this remark!
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
1) the project you attached has two variants (landscape and portrait) but you set landscape by code. If you want to use only the landscape mode, you should simply set:
B4X:
#SupportedOrientations: landscape
and you can delete
B4X:
p.SetScreenOrientation(0)


In the Designer they are positioned for my development device
2) has your development device a resolution of 480x320-160dpi?;

3) if you want to stay mentally healthy, give a logical name to each label :D (at least, give them "clockwise" numbers);

4) are you sure you want the labels' positions exactly as they are in the Designer???;

5) Label1 is covered by the other two or overlaps them (in the Designer);

6) the link you posted to B4A UI Cloud output returns a "not found" error;

7) I'm attaching a project with a partial variant script, you can complete it. I changed colors and alpha values to see what happen!


[P.S. given that I'm not Erel (unfortunately :(:D) you can pay $1,000 only :p]
 

Attachments

  • lmPositionTest.zip
    9.6 KB · Views: 134
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
And again, @Sanxion, please note that this is and will continue to be an open forum, where each question is put to the whole community, and not only one member, even if it happens to be @Erel all mighty! He himself usually often makes this remark!

Anyway, Erel made all GUIs of all my apps I published on Goolge Play!!! (for free, of course)


[NOTE: I never published apps :D]
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
1) the project you attached has two variants (landscape and portrait) but you set landscape by code. If you want to use only the landscape mode, you should simply set:
B4X:
#SupportedOrientations: landscape
and you can delete
B4X:
p.SetScreenOrientation(0)



2) your development device has a resolution of 480x320-160dpi?;

3) if you want to stay mentally healthy, give a logical name to each label :D (at least, give them "clockwise" numbers);

4) are you sure you want the labels' positions exactly as they are in the Designer???;

5) Label1 is covered by the other two or overlaps them (in the Designer);

6) the link you posted to B4A UI Cloud output returns a "not found" error;

7) I'm attaching a project with a partial variant script, you can complete it. I changed colors and alpha values to see what happen!


[P.S. given that I'm not Erel (unfortunately :(:D) you can pay $1,000 only :p]

Thank-you for the response Luca.

Before I hand over the $1000 - I am slightly confused...I have tested your project on my device and the labels are all in the correct position. But if I test it using the cloud service, the labels on the three devices (image attached) are all at different positions.

So...which part am I supposed to complete? When I look in the Designer, I can't see any script other than the usual "'All variants script AutoScaleAll" - have I missed something obvious?
 

Attachments

  • Test.JPG
    Test.JPG
    53.5 KB · Views: 158
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
have I missed something obvious?

I think... yes.

You should read 1 or 2 pages of the guides written with passion and fatigue by Klaus.

Select a Variant and select its relative script.
I set only the bottom position of labels and the left position of Label1 (you should add lines to set the left positions of the other labels, in relation to the first).
The layout name I used is layMain, then open it.
upload_2015-12-26_2-4-42.png




Before I hand over the $1000
I was joking, of course; the real price is $10,000 :p
 
Last edited:
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I noticed only now that all views have Activity as Parent (I wonder why to center lblMain I had to add Panel1 Left & Top).
This is "wrong": all labels' parent should be Panel1 (for convenience).

In addition, after centering lblMain, the alignments do not match (I thought it was already centered).

In short, you have to calculate the initial distances as percentage and apply them through the script.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
We have ALL had this or a similar issue with our GUI

Yes I have issues, but at least I readed and understand the basics before asking. Whats the point of asking, get and answer and dont even know how the designer works to use the answer (like the one by LucaMs)?

, Klaus has a B4X User's Begginers Guide, with entire chapters dedicated to the management of the GUI, you should check it out.

LOL, you ended saying the same thing, read the Begginers Guide


And I must ask, why use an external lib to accomplish something that is simple to achieve with core methods?

Shure, 8 labels are no problem. But as he said, this is just an example. Hundreds of labels in the real project are not really the best approach.
 
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
I think... yes.

You should read 1 or 2 pages of the guides written with passion and fatigue by Klaus.

Select a Variant and select its relative script.
I set only the bottom position of labels and the left position of Label1 (you should add lines to set the left positions of the other labels, in relation to the first).
The layout name I used is layMain, then open it.
View attachment 39997

Thanks Lucas...the reason why I couldn't see your code in the Script-Variant tab is because I was looking at the bottom of the screen. In my environment it is at the side at the top :) - that and it was also past midnight at the time...

I understand now what you have done and will see if I can progress it.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I answer only today, because yesterday I took a day off from B4x.

and have been in contact with one particularly prominent member of this forum
This guy is me.

Unfortunately the problem was not explained with enough details.

Here the problem:
Sanxion wants to add vowel mark to an arabic text. These are the small Labels in his layout.
The problem is not the positioning of these Labels according to the central Label containing the arabic text.
These positions are OK.
The problem is that arabic text is displayed differently in size and shape on different devices with the same layout.
Same TypeFace.DEFAULT and same TextSize with and without AutoScale !

For those interested, the differences are evident if you send the layout of the project in post#1 to the B4A UI Cloud.
The link in post#1 is no more active.
Two pictures from the B4A UI Cloud:
Galaxy Note (5.3'' phone)
upload_2015-12-26_13-21-46.png


Galaxy S4 (5'' phone)
upload_2015-12-26_13-23-1.png


Below a picture showing the difference on my two devices with the same layout and no AutoScale:
Left Sony xperia z1 5'' screen right Asus TF700 10'' screen
The text is smaller on the Sony than on the Asus!
Even the positions of the two dots in the middle of the text are not exavty on the same relative postions.
They are a bit more to the right on the Sony in the left image.
upload_2015-12-26_13-13-41.png


I don't know if there exist a 'standard' arabic font set showing the text exactly the same on different devices.
 
Last edited:
Upvote 0

Sanxion

Active Member
Licensed User
Longtime User
Thank-you for the clarification Klaus.

I would like to apologise for my inadequate description and any consequent misundertanding caused.

I have also amended the title of the post and removed the reference to Erel - my apologies to him and to anybody else that it may have offended.
 
Upvote 0

ivan.tellez

Active Member
Licensed User
Longtime User
Sanxion wants to add vowel mark to an arabic text. These are the small Labels in his layout.
The problem is not the positioning of these Labels according to the central Label containing the arabic text.
These positions are OK.

Ok, thats nothing to do with the original title of the post.

But I think I already give him the answer:

Also search for using custom fonts, to mantain the same look across devices.

Android uses diferent fonts for diferent API levels and languages like NOTO and ROBOTO, so, its not posible to have the exact same font on every device unles you use a custom font.

Maybe consider using DroidSansArabic or the GNU FreeFont.




PS: I´m not shure if custom Typefaces can be tested on the UI Cloud, its better to test on real devices.
 
Upvote 0
Top