Thursday, June 30, 2011

無法讀到指定解析度的目錄的問題

今天在開發時遇到當我希望程式去依手機規格︰hdpi去跑drawable-hdpi的目錄時,
程式卻不理我們而老是讀取drawable-mdpi目錄圖檔的問題。

其實這個問題發生在這裡︰
請參閱Android SDK文件<supports-screens>
android:anyDensity
Indicates whether the application includes resources to accommodate any screen density. Older applications (before API Level 4) are assumed unable to accomodate all densities and this is "false" by default. If the application has set either minSdkVersion or targetSdkVersion to "4" or higher, the default value for this is "true". Otherwise, it is "false". You can explicitly supply your abilities here. Based on the "standard" device screen density (medium dpi), the Android framework will scale down application assets by a factor of 0.75 (low dpi screens) or scale them up by a factor of 1.5 (high dpi screens), when you don't provide alternative resources for a specifc screen density. The screen density is expressed as dots-per-inch (dpi). Android在新開一個專案時, Manifest裡的minSdkVersion預設為2, 難怪我當時一直無法讓程式去跑drawable-hdpi解析度的drawable目錄

No comments: