Android: Using FEATURE_NO_TITLE with custom ViewGroup leaves space on top of the window

不问归期 提交于 2019-12-05 07:42:52
Hounshell

It's not a full answer, but in the meantime you can work around the problem by wrapping your custom layout in a <FrameLayout />

Also, it's worth noting that your layout extends beyond the bottom of the screen. It's shifted down by the title bar height (38 pixels in my emulator)

Edit: Got it. onLayout() (and the corresponding layout() method) specify that the coordinate are not relative to the screen origin, they're relative to the parent ( http://developer.android.com/reference/android/view/View.html#layout%28int,%20int,%20int,%20int%29 ). So the system is telling you that you're at relative coordinates (0, 38), and you're adding it when passing that down to your child, which means that you're saying that your child is at screen coordinates (0, 76), causing the gap.

What you actually want to do is:

v.layout(0, 0, r - l, b - t);

That will put your child Views aligned with the top left corner of your View, with the same width and height as your view.

Abdo

I had the same issue with a FrameLayout in 2.2

I fixed it by adding android:layout_gravity="top" to the FrameLayout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!