简体   繁体   English

空的linear_layout具有wrap_content故障

[英]Empty linear_layout with wrap_content glitch

I have empty LinearLayout with height set to wrap_content and it takes too much space. 我有高度设置为wrap_content的空LinearLayout,它占用了太多空间。 Should be padding or zero, but it takes around 80dp. 应该为padding或为零,但大约需要80dp。 Why? 为什么? It is strange. 它很奇怪。

(same with any count of child inside, should takes space only to "cover" children, but takes more) (与内部任何数量的儿童相同,应该只占用空间以“掩盖”儿童,但要占用更多空间)

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/blue_bg"
</LinearLayout>

EDIT: 编辑:

I've found the reason. 我找到了原因。 Background drawable expands LinearLayout. 背景可绘制对象可扩展LinearLayout。 Ridiculous. 荒谬。 How to fix this? 如何解决这个问题?

Make your background smaller. 缩小背景。 You might want to use 9 PNG to make the image stretch nicely within your layout. 您可能要使用9 PNG来使图像在布局中很好地拉伸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM