如何覆盖 config.xml 中的值? [英] How to overlay a value in config.xml?

查看:42
本文介绍了如何覆盖 config.xml 中的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从Android框架的源代码来看,有一个名为config.xml的文件,它存储了Android内部使用的一些值.

From the source code of Android framework, there is a file named config.xml which stores some values Android uses internally.

并且有一个值控制手指之间的最小距离,这将被视为缩放手势:

And there is a value which controls the minimum distance between fingers that will be considered a scale gesture:

<!-- Minimum span needed to begin a touch scaling gesture.
     If the span is equal to or greater than this size, a scaling gesture
     will begin, where supported. (See android.view.ScaleGestureDetector)

     This also takes into account the size of any active touch points.
     Devices with screens that deviate too far from their assigned density
     bucket should consider tuning this value in a device-specific overlay.
     For best results, care should be taken such that this value remains
     larger than the minimum reported touchMajor/touchMinor values
     reported by the hardware. -->
<dimen name="config_minScalingSpan">27mm</dimen>

正如上面所说,如果我们想修改这个值,我们可以

As it says, if we want to modify this value, we can

在特定于设备的叠加层中调整此值.

tune this value in a device-specific overlay.

经过简短的谷歌搜索后,作为应用开发者,我找不到任何修改此值的方法.

After a brief Googling, I cannot find any method of modify this value as an app developer.

我还尝试在我的项目的 res/values 下添加一个名为 config.xml 的新文件,但它不起作用.

I also tried to add a new file named config.xml under res/values of my project, but it does not work.

这可能吗?我只是想调整被视为缩放手势的最小距离,但是 ScaleGestureDetector 没有这样的 API.

Is this possible? I just want to adjust the minimum distance to be considered as a scaling gesture, but ScaleGestureDetector has no such API.

推荐答案

我知道这是一个老问题,但我会回答,以防其他人遇到同样的问题.请注意,这是在创建自定义 Android ROM 构建时完成的方式.由于权限的原因,它可能不适用于 Android APK.但是,如果您希望在自定义 ROM 中执行此操作,请继续阅读.

I know this is an old question, but I'll answer it in case someone else is stuck on this same thing. Note, this is how it is done when creating a custom Android ROM build. It is likely not going to work with an Android APK due to permissions. However, if you wish to do this within your custom ROM, keep reading.

这很容易做到.这是我如何尝试在 android 设置中覆盖 config.xml 文件的示例:

It's quite easy to do. Here's an example of how I would try overlaying a config.xml file in android Settings:

  1. 在项目的顶部,创建一个名为overlay"的新目录
  2. 在该目录中创建一个与您希望更改的包/应用程序/设置中的配置文件位置相对应的路径packages/apps/Settings/res/values
  3. 将 Android 源中的 config.xml 复制/粘贴到您的新目录(在 values 文件夹中).这降低了出错的风险
  4. 删除您不想修改的所有配置条目,但不要删除 XML 格式!
  5. 您现在可以根据需要对此 config.xml 进行更改
  6. 最后,在您的项目顶部,将以下内容添加到您的 make 文件 (.mk) 中,并使用覆盖目录的正确路径:PRODUCT_PACKAGE_OVERLAYS += \<path/to/overlay/directory/from/step/one>
  7. 完成!您现在可以使用这个单一的覆盖目录来覆盖其他存储库中的其他文件!您在覆盖目录下添加的任何内容现在都应该成功应用(只要路径/文件与 Android 源正确匹配)
  1. At the top of your project, create a new directory named "overlay"
  2. Create a path within that directory corresponding to the location of the config file in packages/apps/Settings you wish to change packages/apps/Settings/res/values
  3. Copy/paste the config.xml from Android source into your new directory (in values folder). This reduces risk of errors
  4. Delete all config entries you don't want to modify, but do not delete the XML formatting!
  5. You can now make your changes to this config.xml as you wish
  6. Lastly, at the top of your project add the following into your make file (.mk) with the proper path to your overlay directory: PRODUCT_PACKAGE_OVERLAYS += \ <path/to/overlay/directory/from/step/one>
  7. Done! You can now use this single overlay directory to overlay other files within other repos as well! Whatever you add beneath the overlay directory should now apply successfully (as long as paths/files match up properly with Android source)

这是我在这个论坛上的第一个ANSWER.希望它可以帮助某人:)

This was my first ANSWER on this forum. Hopefully it helps someone :)

这篇关于如何覆盖 config.xml 中的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆