我尝试将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>
答案 0 :(得分:2)
LinearLayout's
身高为"wrap_content"
。这意味着它需要内容的高度(您的背景)。您可以将其更改为"match_parent"
或在dp
中为其指定固定大小。所以即使背景也一样。
答案 1 :(得分:0)
如果您希望它是固定的,请使用dp中的固定高度和宽度或动态计算旧背景的高度和宽度,然后应用新的背景,并将LinearLayout的高度和宽度设置为您以编程方式计算的大小。
答案 2 :(得分:0)
我只是将其替换为另一个容器,例如ConstraintLayout
。我没有时间弄清楚它。