如何让Android应用程序支持多种屏幕尺寸以<支持屏 [英] How to have android application support multiple screen sizes with <supports-screens

查看:146
本文介绍了如何让Android应用程序支持多种屏幕尺寸以<支持屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我用下面的code下面有我的应用程序扩展在不同的Andr​​oid设备的屏幕尺寸,但是当我在我的Nexus 7测试它不能扩展和,如果它是一个4英寸的屏幕上。当我在模拟器上7英寸的屏幕上运行它的工作原理。什么毛病我的清单文件?

So I used the following code below to have my application to scale screen size on different android devices but when I am testing on my Nexus 7 its does not scale and its as if it was on a 4 inch screen. When I run it in the emulator on a 7 inch screen it works. Anything wrong with my manifest file?

<supports-screens 
android:resizeable="true"
android:smallScreens="true" 
android:largeScreens="true"
android:xlargeScreens="true"  
android:normalScreens="true" 
android:anyDensity="true"
/>

这code云应用部分权利之前吧?

this code goes right before the "application" part right?

推荐答案

好吧,所以你必须要知道的是,支持屏不会使你的应用程序的外观您所支持的屏幕好(检查此链接)。它只是告诉用户这样的屏幕就可以下载你的应用程序,但它是由你来使其正常显示。你必须创建你自己的特定的屏幕布局。

Ok, so what you have to know is that support-screens doesn't make your application look 'nice' on screens you are supporting (check this link). It just tells that users with such screens will be able to download your application, but it's up to you to make it display properly. You have to create layouts for specific screens on your own.

更多关于它,你可以Android的文档中写着: http://developer.android。 COM /引导/做法/ screens_support.html

More about it you can read in Android's documentation: http://developer.android.com/guide/practices/screens_support.html

基本上,你必须正确地命名的目录中,布局文件存储在为了让Android的知道哪一个应该拿起特定设备。例如,如果你的布局的文件是layout.xml你应该有:

Basically, you have to properly name your directories in which layout files are stored in order to let Android know which one should it pick up for specific device. If for example your layout's file was "layout.xml" you should have:

/res/layout/layout.xml         // Default layout
/res/layout-small/layout.xml   // Small screens
/res/layout-large/layout.xml   // Large screens
/res/layout-xlarge/layout.xml  // Extra large screens

您可以更进一步,让也不同布局纵向在specyfing另一个关键字目录的景观的意见名称:

You can go even further and make also different layouts for portrait and landscape views by specyfing another keyword in directory's name:

/res/layout-small-land/layout.xml      // Small screens, landscape view
/res/layout-small-portrait/layout.xml  // Small screens, portrait view

请记住,标签顺序很重要,所以你的不能布局画像小

这篇关于如何让Android应用程序支持多种屏幕尺寸以&lt;支持屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆