问题
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.
I also tried to add a new file named config.xml
under res/values
of my project, but it does not work.
Is this possible? I just want to adjust the minimum distance to be considered as a scaling gesture, but ScaleGestureDetector
has no such API.
回答1:
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.
It's quite easy to do. Here's an example of how I would try overlaying a config.xml file in android Settings:
- At the top of your project, create a new directory named "overlay"
- 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
- Copy/paste the config.xml from Android source into your new directory (in values folder). This reduces risk of errors
- Delete all config entries you don't want to modify, but do not delete the XML formatting!
- You can now make your changes to this config.xml as you wish
- 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>
- 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)
This was my first ANSWER on this forum. Hopefully it helps someone :)
来源:https://stackoverflow.com/questions/49249703/how-to-overlay-a-value-in-config-xml