2

My BlackBerry Q5 can run Android applications and I'd like to optimize one of my existing apps for its screen. The resolution is 720x720, but the runtime also inserts a bar in the bottom of the screen, so usable resolution for Android app is 720x620 pixels, so I guess that's what the phone reports to Android app as the resolution.

Is there a way to make a layout that will apply only to 720x620px screens? The documentation for supporting multiple screen sizes says that there are w<N>dp and h<N>dp qualifiers, but they use scaled dp units and also means minimum available width in dp units, so they would not be useful in here.

Michael Donohue
  • 11,776
  • 5
  • 31
  • 44
Axarydax
  • 16,353
  • 21
  • 92
  • 151
  • I believe, with the latest BB10 OS (10.2.1), the requirement for the bar at the bottom has been removed, So rather than try to rework your code, I suggest you look at this and see if that helps because I think you will find most users will go to 10.2.1 pretty quickly, especially those using Android since there are major improvements. Just a thought. One other thought 720x720 is the screen size, not resolution. resolution is the pixel density... – Peter Strange Feb 19 '14 at 11:00
  • so it's 720x720 - I still have problems in the original layout that it won't fit to a square screen, so I'd like to prepare a layout for the screen size of 720x720, but only get Blackberry to pick it up. – Axarydax Feb 19 '14 at 11:32
  • Sorry, I should have pointed out that I don't know Android, just wanted to make sure you didn't spend time resolving a short term problem. Hopefully someone with Android skills will help further. Good luck. – Peter Strange Feb 19 '14 at 11:47
  • You can create a separate layout just for these. If i remember correctly, I once used something similar to `drawable-small-square`, which would apply only for Q10 and Q5. – Bojan Kogoj Feb 20 '14 at 00:16
  • layout-small-square is not picked up by my Q5, unfortunately – Axarydax Feb 22 '14 at 19:52

2 Answers2

3

I needed to solve your problem too, this is my solution.

The Q5 and Q10 screen density is xhdpi (scale factor of 2.0) so max screen size is 720x720px / 2.0 = 360x360dpi

Quoting from the documentation, Table 2, "Available height" row:

Specifies a minimum available screen height, in "dp" units at which the resource should be used
[...]
When your application provides multiple resource directories with different values for this configuration, the system uses the one closest to (without exceeding) the device's current screen height.
[...]
Added in API level 13.

Based on these, for Androids with API>=13 (including Blackberrys) you can put your Blackberry specific layout in "layout-h240dp" folder and all the others in "layout-h361dp"

Blackberry height is greater than 240dp and less than 361dp, so it will use layouts in h240dp folder.

Notes:
- If you don't add the 361dp folder, the 240dp folder will be used for every device with height greater than 240dp.
- I choose 240dp because it is a common minimium dimension for today devices.
- 309dp should work too as it less than 310dp (minimum height of BB's screen with bars)
- For Androids with API<13 you have to put a default layout in the generic "layout" folder, because the previous "h*dp" folders are ignored. if default layout is missing, the app should crash.

vfede
  • 106
  • 1
  • 6
0

I don't mean to turn this into a full-blown answer, but I need the extra space.

For your assets, if you'd like to target them specifically for Q5 or Q10 devices, place them in the drawable-square folder. This changed from drawable-small-square due to deprecation.

If you plan on deploying to OS 10.2.1+ devices and don't want that back-bar to show by default, you can add a small configuration file to your app so that the system knows not to show it.

For more information on that, take a look at my blog:

Android Developers: Eliminate the Back-Bar in Your 10.2.1. App

Justin Jasmann
  • 2,363
  • 2
  • 14
  • 18