开发者

Extra space in LinearLayout widget

开发者 https://www.devze.com 2023-02-28 13:58 出处:网络
I\'m not able to figure out why my widget has an extra space on my phone desktop. It has extra space on top and on bottom. It would be gracefulif somebody could help me, I\'ve been struggling with thi

I'm not able to figure out why my widget has an extra space on my phone desktop. It has extra space on top and on bottom. It would be graceful if somebody could help me, I've been struggling with this problem for 2 days now.

Here is my layout xml:

android:layout_height="130px" android:gravity="top" android:minHeight="130px" android:minWidth="152px" android:layout_marginBottom="-30px" android:layout_marginLeft="0px" android:layout_marginRight="0px" android:layout_marginTop="-30px" android:weightSum="0">

My layout should be 152px wide and 130px high!

I tried margin_top = -30px, in emulator it now shows fine, however when开发者_如何学编程 I install it on my phone that extra space is still there!

Kind Regards Raivis


It seems like your emulator screen is smaller than your phone screen.

Try using one item with a static size and the other one with fill_parent for the size. Then if you want spaces between the items you can use the layout margin's

Or you could make a custom view and override onLayout, onMeasure and onSizeChanged.

Then you can set the size in code.

Edit:
Try these in your XML

android:layout_height="fill_parent"
android:layout_width="fill_parent"
0

精彩评论

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

关注公众号