2011-08-19 102 views
0

我实现了支持不同正常屏幕的应用程序。为此,我在res文件夹中创建了3个文件夹(如layout-normal-ldpi,layout-normal-mdpi,layout-normal-hdpi)。在这个我放置不同的XML文件具有相同的名称。但我得到了android.content.res.Resources $ NotFoundException。如何处理这个?有谁能够帮助我。android-如何支持多屏幕

谢谢。

+0

你可以发布一个示例代码或确切logcat的条目? –

+1

尝试项目 - >清除 –

回答

4

的文件夹中创建不正确,请参阅下面的人

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 

下面是PIC的res文件夹结构更简单

enter image description here

+0

它意味着正常屏幕的命名约定---> layout-ldpi,layout-mdpi,layout-hdpi。小屏幕---> layout-small-ldpi,layout-small-mdpi,layout-small-hdpi。大屏幕---> layout-large-ldpi,layout-large-mdpi.layout-large-hdpi.is它是否正确? – naresh

+1

没有什么像layout-small-ldpi,但是它的布局布局很小,等等,以及drawables的drawable-mdpi等,如上所述 – ingsaurabh

+0

我的屏幕尺寸是240x400(这意味着正常的屏幕ldpi)。为此,它不需要布局文件夹中的xml文件为什么? – naresh

0

我认为'正常'和'dpi'是多余的。 我想你已经看过here,但也许应该再次查看它。