2

values我有我的默认文件夹dimens.xml。现在碰巧我需要为mdpi设备使用一些其他值。为了实现这一点,我必须指定替代资源,即values-mdpi\dimens.xml. 但是一旦我这样做,我必须定义values-xhdpi,values-hdpi等,以显示不同密度屏幕的正确尺寸。所以基本上为了定义mdpi设备的唯一值,我需要创建几个不同的文件。有没有简单的方法来定义价值,mdpi仅此而已?

4

2 回答 2

1

Yes, there is a solution.

If you use maven to build your application, you can make a folder with name eg. yourproject-res in the same place where res folder is. Then you can put anything you want to this folder (like drawable folder, layout folder, drawable-mdpi folder, values folder etc.). After that you need to modify your pom.xml to create second profile of your application, like:

    <profile>
        <id>yourprojectmdpi</id>            
        <properties>
            <package.name>.com.your.app</package.name>
            <res.directory>yourproject-res</res.directory>      
        </properties>
    </profile>

And then the last step is to clean install your application with maven using -P parameter to point on your defined profile.

mvn clean install -Pyourprojectmdpi

and then

mvn android:deploy android:run to send apk from target folder to your device and run.

Here, here and here you have a reference to maven profiles.

I hope I correctly understood your problem.

于 2013-04-15T16:54:52.767 回答
1

我对 android 比较陌生,但我很确定如果您不为任何其他大小指定资源,则将使用默认值目录中的值。

请参阅支持多个屏幕以及如何确定正确资源的 android 文档页面。

http://developer.android.com/guide/practices/screens_support.html http://developer.android.com/guide/topics/resources/providing-resources.html#BestMatch

于 2013-04-15T16:31:26.347 回答