开发者

Android Views appear different when accessed via a JAR in libs

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:

  1. I'm running my project, directly launching the Activity (Manifest LAUNCHER definition).
  2. 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:

  1. making sure all my dimensions are in DiPs
  2. converting my DiPs values to scaled View dimensions using getWindowManager().getDefaultDisplay().getMetrics() and TypedValue.applyDimension()
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜