2012-07-18 133 views
1

我知道在Android中支持多個屏幕,我在我的應用程序中使用它。但支持不同的屏幕尺寸和DPI會使您的應用程序規模變大。我們都知道Google Play中50mb的文件大小限制?那麼,是否有可能創建一個如下所示的文件夾?Android支持屏幕設計

\layout-small-160 
\layout-normal-240 

如果做任何一件不可能知道這裏如何支持多種屏幕尺寸和DPI的,而無需使用過多的圖片,讓我的應用程序的大小更小?

+0

你可以爲多個屏幕創建多個apk並加載它。 – 2012-07-18 08:01:29

回答

2

我只給我的建議,你可以試試。

默認情況下,我們有三個可繪製文件夾drawable-ldpi(120),drawable-mdpi(160),drawable-hdpi(240)。

當應用程序需要圖像時,Android會根據屏幕命運找到圖像。顯然,drawable-ldpi文件夾中的圖像適用於手機上運行的應用程序命運較低的應用程序。

但是,如果在drawable-ldpi文件夾中沒有圖像。 Android會查找drawable-hdpi中是否有圖像。如果它存在,android會縮放圖像(0.5)並顯示它。

所以你不需要爲每個命運準備圖像。您只需要爲hdpi scrren準備圖像。對於需要準確尺寸的個別圖像,您需要爲這三項命運做好準備。

您可以下載一些着名的APK並提取它們。然後輸入res文件夾以檢查作者的工作方式。

對不起,我英文很差。

+0

您是指apk工具? – thenewbie 2012-07-19 02:40:17

+0

謝謝你給我一個主意.. – thenewbie 2012-07-19 03:02:28

+0

你可以下載Skype.apk(Skype的Android包)並提取它。你可以看到res文件夾。您可以檢查Skype客戶端開發人員如何解決它。 – 2012-07-19 03:47:35

0

2建議:

  1. 調整圖像到正是你需要的大小。使用適當的壓縮(使用專業應用程序來編輯圖像,例如優化圖像並壓縮它的photoshop)。
  2. 將部分圖像放在外部服務器上,並在首次使用時下載全部圖像。從服務器下載圖像的優點是您知道設備尺寸,因此您只能下載相關尺寸。
+0

但大多數不擅長技術的用戶不喜歡這樣的.. – thenewbie 2012-07-18 07:42:52

+0

我不明白什麼東西不喜歡? – 2012-07-18 08:13:05

0

病例密切..這是更多鈔票,以創建一個有兩個修改一個文件夾..

這樣

佈局正常華電國際----這將只設置從特定的觀點手機,擁有240 dpi和正常畫面

感謝所有誰評論,並給這裏的想法..

1

Supporting Multiple Screens文章Android文檔的:

To optimize your application's UI for the different screen sizes and densities, you can provide alternative resources for any of the generalized sizes and densities. Typically, you should provide alternative layouts for some of the different screen sizes and alternative bitmap images for different screen densities. At runtime, the system uses the appropriate resources for your application, based on the generalized size or density of the current device screen. 

因此,是的,可以爲您的問題中提到的不同佈局創建文件夾。以下是有你的資源文件夾中組織了不同的屏幕尺寸和不同的位圖資源的一個很好的做法:

res/layout/my_layout.xml    // layout for normal screen size ("default") 
res/layout-small/my_layout.xml  // layout for small screen size 
res/layout-large/my_layout.xml  // layout for large screen size 
res/layout-xlarge/my_layout.xml  // layout for extra large screen size 
res/layout-xlarge-land/my_layout.xml // layout for extra large in landscape orientation 

res/drawable-mdpi/my_icon.png  // bitmap for medium density 
res/drawable-hdpi/my_icon.png  // bitmap for high density 
res/drawable-xhdpi/my_icon.png  // bitmap for extra high density 

然而,你不必爲屏幕大小和密度的組合提供替代資源。如果您按照說明here中的說明開發應用程序,系統將提供強大的兼容性功能,可處理在任何設備屏幕上呈現應用程序的大部分工作。