I'm working on a reusable library for Android. The library will include an Activity that developers can use in their apps.
The plan is to distribute the library as a JAR. Consequently, I'm laying out views at runtime in my Activity onCreate(), as I can't use XML resources.
However, I'm noticing this weird behavior where there are subtle size differences between my Activity in two contexts:
- I'm running my project, directly launching the Activity (Manifest LAUNCHER definition).
- I zip my p开发者_StackOverflowroject classes into a JAR, and import that JAR into another Android project (testing what other developers will do). This wrapping project fires an intent for my Activity.
Why would this be?
What I see is that the imported lib version (2) looks smaller. It's some kind of scaling factor that's being applied to the direct launch case (1) that isn't being applied to the imported lib.
I have tried:
- making sure all my dimensions are in DiPs
- converting my DiPs values to scaled View dimensions using
getWindowManager().getDefaultDisplay().getMetrics()
andTypedValue.applyDimension()
精彩评论