Android resource notlong / long identifiers not working

up vote 1 down vote favorite 1

Currently I have the following resource folders:
1. layout-sw600dp
2. layout-sw600dp-notlong

The idea is that we have 3 types of devices and the devices should use the resources from the correct folder accordingly. The devices are:
1. Samsung Galaxy Tab 10.1, 1280 X 800 mdpi. 16/10
2. Asus Transformer TFT 101, 1280 X 800 mdpi. 16/10.
3. A generic tablet, 800 X 600 ldpi. 4/3.

The problem is that all 3 devices use resources from layout-sw600dp-notlong. To my understanding 4/3 is categorized as -notlong devices.

Is there anything wrong in my identifier usage? Or there's a bug reported for the identifier?

Thank in advance.

android screen ratio
share | improve this question edited Aug 1 '12 at 4:37
asked Aug 1 '12 at 4:00 Maziz
28 4

3 Answers

active oldest votes
up vote 2 down vote accepted

The 'notlong' identifier is for devices that are similar in aspect ratio to baseline devices (seehttp://developer.android.com/guide/practices/screens_support.html). While the docs are scarce on what baseline devices are, typical resolution of Android devices 1.5~1.6. So what you are seeing is correct.

While there is a 'long' identifier for devices that are longer than baseline ratios, it looks like you can't force resources for devices that are shorter (e.g. 800x600).

share | improve this answer edited Aug 1 '12 at 22:12
answered Aug 1 '12 at 22:07 ebernie
93 8
Short question. Based on your explanation, shouldn't the 1280 X 800 resolution use the resource in -long folder and not -notlong?– Maziz Aug 1 '12 at 22:15
1280x800 has a ratio of 1.6. I'm assuming it is close enough to baseline (800/480 = 1.6, 480/320 = 1.5) that it's using the 'notlong' resources. So no, it won't use the 'long' resources.– ebernie Aug 2 '12 at 20:54
This sdk omission is a shame :/– nobre Feb 6 at 19:39
up vote 0 down vote

you have read this doc?http://developer.android.com/guide/practices/screens_support.html#DeclaringTabletLayouts

share | improve this answer answered Aug 1 '12 at 4:25 ilsy
81 3
I did, thanks for the link. Indeed yoou can specify the smallest width, but it's not the width of the application it's trying to adapt but the aspect ratio of the device.– Maziz Aug 1 '12 at 5:06
up vote 0 down vote

According to the source code. (framework/base/core/java/android/content/res/Configuration.java)

 // Is this a long screen? if (((longSizeDp*3)/5) >= (shortSizeDp-1)) { // Anything wider than WVGA (5:3) is considering to be long. screenLayoutLong = true; } else { screenLayoutLong = false; }

So if the aspect ratio is wider than 3:5(or 1.667), it will be treated as long screen.

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android调用相机相册并显示照片在ImageVi
  2. Android:监听WIFI网络状态
  3. What Android(安卓)Chipset Can Support
  4. Android(安卓)获取CPU架构(指令集)
  5. Android(安卓)使用广播(BroadcastReceiver
  6. Android(安卓)创建与解析XML(五)—— Dom4j
  7. Android(安卓)自定义seekbar
  8. Android(安卓)代码中实现返回键功能
  9. Android中ContextMenu的使用
  10. android 对话框总结