Android Code Snippet Code Multi Devices

I make custom apps for sailors. Now and then I run into something that makes my programing easy. Scaling a map or any apps to fit on many different devices has been time consuming. Not the view’s location on the display, but what is inside the view. Almost all of my map tracking programs, and other GPS programs use an Image View to display the track. The device adjusts the Image View to fit the display and I have been adjusting my code to match the Image View. It’s a simple routine that checks for the height and width of the new device and modifies the code.

FixV = PositionHeight
If ImageView1.Height = 1691 Then

Else If ImageView1.Height < 1691 Or ImageView1.Height > 1691 Then
VertAdj = ImageView1.Height / 1691
PositionHeight = FixV * VertA

This may be old news for some members, but new for others like me. I can currently program once and it works on everything. The little phone and the 8-inch tablet are using the same program in the picture. The little red dot is my location on both devices.







 

LucaMs

Expert
Licensed User
Longtime User
(You should use Code tags when posting source code)



This is your code:
B4X:
FixV = PositionHeight
If ImageView1.Height = 1691 Then

Else If ImageView1.Height < 1691 Or ImageView1.Height > 1691 Then
VertAdj = ImageView1.Height / 1691
PositionHeight = FixV * VertA

1 - you should use dips (1691dip)
2 - no code after that "Then"?
3 - the "Else If line" can be replaced with "Else"
4 - 1691: Why???


You should only calculate the base/height ratio of the content to be displayed and exploit the maximum portion of the display possible while maintaining that proportion, unfortunately leaving unused spaces.

This is exactly what I was writing in the Italian forum. Old TV programs recorded in 4:3 format, viewed on today's TVs, ALL 16:9, have black bars on the sides.

Thank you, display manufacturers, don't standardize displays, like those on TVs, you risk getting sick! ? ? ? ? ? ? ? ? ? ?
 

Sailboat11

Member
Licensed User
Thanks for your comments. I learn something every time I visit the Forum.

I had a tag paragraph that explained my code but lost it in my graphic's placement. Sorry about that. I use a reference phone to program and skip the code on that phone. I also lost some of that code.

The good thing about custom apps is that you normally talk to the customer one on one. My biggest problem is the software is too complicated for the user to use. I have been programming my apps to 12. I hear that 13 is going to be more difficult to communicate with files. That's how we teach sailing. Thanks
 

Sailboat11

Member
Licensed User
I think a better example of this code use or similar code is the Google Map apps. The GPS input follows the map in the apps no matter what device you are using. I think they modify their code to fit the container for each device.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…