Android Question Activity Background images

Stulish

Active Member
Licensed User
Longtime User
Is there a way to change the activity background image depending on if the tablet is in Portrait or Landscape within Designer Scripts??

I have a similar graphic for both but if i use the portrait version it looks squashed in landscape, so i created 2 images (see below)

1602802113632.png
1602802133408.png


I just wondered if these could be changed depending on tablet orientation from within the designer scripts or it it needs to be done within the main code?

Thanks for any help

Stu
 

LucaMs

Expert
Licensed User
Longtime User
I give you a bad news: the image may appear squashed or enlarged in both portrait and landscape, regardless of whether you decide which one to use.

This is because the image you use has a certain ratio of height to width while the devices are all different from each other (thanks to all the manufacturers for not standardizing this, I hope you get an amazing diarrhea ?).

However, as far as I know it is not possible to make this choice in the Designer.

To prevent the image from being distorted, from code you should use this:
https://www.b4x.com/android/forum/t...t-images-without-distortion.86627/post-548417
 
Upvote 0

Stulish

Active Member
Licensed User
Longtime User
I give you a bad news: the image may appear squashed or enlarged in both portrait and landscape, regardless of whether you decide which one to use.

This is because the image you use has a certain ratio of height to width while the devices are all different from each other (thanks to all the manufacturers for not standardizing this, I hope you get an amazing diarrhea ?).

However, as far as I know it is not possible to make this choice in the Designer.

To prevent the image from being distorted, from code you should use this:
https://www.b4x.com/android/forum/t...t-images-without-distortion.86627/post-548417
Thanks LucasMs,

I thought that might be the case, but thought i would ask.

I will be creating this app for a specific size screen and resolution/DPI so it should only be used on 2 different devices, so i could do something within the main code.

Regards

Stu
 
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
Hello, but with the code you can replace images when the phone changes its orientation from portrait to landscape and vice versa. Somewhere I saw the appropriate code on the forum.
 
Upvote 0

Stulish

Active Member
Licensed User
Longtime User
Hello, but with the code you can replace images when the phone changes its orientation from portrait to landscape and vice versa. Somewhere I saw the appropriate code on the forum.
Thanks Kisoft, i have done that before i just wondered if the designer scripts could do it :)
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Is there a way to change the activity background image depending on if the tablet is in Portrait or Landscape within Designer Scripts??

I have a similar graphic for both but if i use the portrait version it looks squashed in landscape, so i created 2 images (see below)

View attachment 101592 View attachment 101593

I just wondered if these could be changed depending on tablet orientation from within the designer scripts or it it needs to be done within the main code?

Thanks for any help

Stu
For a simple image such as that, you may wish to investigate 9patch images: https://www.b4x.com/android/forum/threads/nine-patch-images-tutorial.14283/#post80908
 
Upvote 0

Stulish

Active Member
Licensed User
Longtime User
Thanks Jeffrey, i will take a look :)
 
Upvote 0
Top