2012-11-14 47 views
2

假设我在非DPI主布局资源文件夹中有一个布局,并且该布局执行hdpi/mdpi/ldpi文件夹中存在的子布局的<include>。我可以期望最终的充气布局根据设备DPI聚合h/m/l-dpi子布局,就像“完整”布局一样吗?对于完整的布局,是否将包含Android布局在hdpi/mdpi/ldpi布局之间进行选择?

谢谢!

+0

你在模拟器上试过这个吗? :D –

+0

为什么你有不同的*布局*的屏幕密度? – CommonsWare

+0

你真的是指*布局*吗? –

回答

0

虽然在帖子发布时我没有机会测试帖子的命题,但我后来有机会这样做,因此会回答我自己的问题,因为没有其他人这么做了。

是,以下情形作品如预期(在API级别8测试):

布局/ main.xml中:

... <include layout="@layout/included"/> ... 

布局/ included.xml:

<merge xmlns:android="http://schemas.android.com/apk/res/android"> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="GENERIC included fragment"/> 
</merge> 

layout-ldpi/included.xml:

<merge xmlns:android="http://schemas.android.com/apk/res/android"> 
    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="LOW-DPI included fragment"/> 
</merge> 

在QVGA设备上运行应用程序呈现一个视图,其中包含的部分来自LDPI目录,而非LDPI设备从布局目录中抓取默认的部分。