我想提供相同的图像资源/绘图两个可绘制-xlarge-mdpi和可绘制-sw600dp-mdpi。
这样做的唯一方法似乎是在res/下创建两个文件夹,并将同一组资源复制到每个文件夹中。
有了布局,我们就可以进行混叠。例如,在values文件夹中创建一个带有特定限定符的名为layout.xml的文件,并为这两个限定符添加指向单个布局文件的项:
这两个文件的内容都类似于:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="activity_shows" type="layout">@layout/activity_shows_tablet</item>
</resources>(匹配xlarge的设备或匹配sw600dp的设备现在将使用activity_shows_tablet.xml作为“activity_shows”的布局文件)
对于抽屉是否有类似的方法?
发布于 2012-05-02 18:04:37
对于抽屉是否有类似的方法?
它应该和布局一样工作。
将png资源放入默认文件夹
res/drawable/largescreen.png
res/drawable/smallscreen.png创建引用.xml的png资源
res/drawable/image.xml
res/drawable-xlarge-mdpi/image.xml
res/drawable-sw600dp-mdpi/image.xml其中image.xml类似于(文档)
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="@drawable/largescreen" />然后使用XML资源,就像直接使用png一样。
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:src="@drawable/image" />https://stackoverflow.com/questions/10418926
复制相似问题