我试图将 LinearLayout 的背景更改为某种木质纹理,但它会根据木质背景的尺寸改变 LinearLayout 的宽度和高度! 我需要 LinearLayout 来忽略背景尺寸!
<LinearLayout
android:id="@+id/LinearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/wood"
android:orientation="vertical" >
some content here which I need to wrap height to them!
</LinearLayout>
最佳答案
您的LinearLayout 的
高度是"wrap_content"
。这意味着它需要内容的高度(你的背景)。您可以将其更改为 "match_parent"
或在 dp
中为其指定固定大小。这样即使有背景也能保持不变。
关于android - 改变 LinearLayout 的背景会改变它的宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26687522/