2012-07-18 75 views
0

在我的Android應用程序中,我爲大型和x型大屏幕設置了佈局資源,即: layout-large和layout-xlarge。當我打開在具有「大」屏幕的設備模擬器中運行它時,它從「layout-large」文件夾中獲得佈局,這似乎是正確的。但是,當我使用x大屏幕尺寸的設備時,它仍然使用「佈局大」資源。Android設備如何識別要使用的佈局

我使用的X-大型設備爲10" ,1280×800,240dp模擬器任何想法

我已經包括在清單如下:?

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

您是否在清單文件中聲明瞭您的應用支持哪種屏幕尺寸? – 2012-07-18 12:42:41

回答

2

下面的鏈接將幫助您瞭解如何機器人拾起佈局文件在各種設備上

http://developer.android.com/guide/practices/screens_support.html

+0

我仔細閱讀了文檔,並做了相應的處理。 – desidigitalnomad 2012-07-18 12:54:38

+0

是否有任何替代的Android設備模擬器可以使用?我不相信Eclipse – desidigitalnomad 2012-07-18 12:57:26

+0

中提供的默認AVD管理器,我們使用谷歌提供的AVD管理器創建的模擬器是我們可以使用的最好的模擬器。另外,請注意術語'模擬器'。它模擬真正的硬件。不像'模擬器',如果它在創建的'模擬器'上工作,它也應該在真實設備上工作 – sunil 2012-07-18 13:08:48

1

你確定該文件夾名字是layout-xlarge而不是layout-x-largeDOC

+0

抱歉,我的意思是layout-xlarge – desidigitalnomad 2012-07-18 12:46:58

0

按照佈局

在運行時的運行時渲染Android文檔,系統確保當前屏幕與對於任何給定資源的以下過程的最佳可能的顯示:

The system uses the appropriate alternative resource 

Based on the size and density of the current screen, the system uses any size- and density-specific resource provided in your application. For example, if the device has a high-density screen and the application requests a drawable resource, the system looks for a drawable resource directory that best matches the device configuration. Depending on the other alternative resources available, a resource directory with the hdpi qualifier (such as drawable-hdpi/) might be the best match, so the system uses the drawable resource from this directory. 
If no matching resource is available, the system uses the default resource and scales it up or down as needed to match the current screen size and density 

The "default" resources are those that are not tagged with a configuration qualifier. For example, the resources in drawable/ are the default drawable resources. The system assumes that default resources are designed for the baseline screen size and density, which is a normal screen size and a medium density. As such, the system scales default density resources up for high-density screens and down for low-density screens, as appropriate. 

However, when the system is looking for a density-specific resource and does not find it in the density-specific directory, it won't always use the default resources. The system may instead use one of the other density-specific resources in order to provide better results when scaling. For example, when looking for a low-density resource and it is not available, the system prefers to scale-down the high-density version of the resource, because the system can easily scale a high-density resource down to low-density by a factor of 0.5, with fewer artifacts, compared to scaling a medium-density resource by a factor of 0.75.