3

I tried to change background of a LinearLayout to some wood texture, but it changes LinearLayout width and height depending on dimensions of the wooden background! I need LinearLayout to disregard background dimensions!

<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>
AVEbrahimi
  • 17,993
  • 23
  • 107
  • 210
  • 1
    Might be useful : http://stackoverflow.com/questions/8202647/setting-a-background-image-to-a-view-stretches-my-view – Blaze Tama Nov 01 '14 at 08:44

3 Answers3

4

Your LinearLayout's height is "wrap_content". Which means it takes height of the content(your background). You can change it to "match_parent" or give it a fixed size in dp. So that it remains same even with background.

Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109
0

If You want it to be of fixed either use fixed height and width in dp Or dynamically calculate height and width of old background and then apply new background with setting LinearLayout height and width to be of size you calculated programatically.

Akash Jindal
  • 505
  • 3
  • 7
0

I simply replaced it with another container such as ConstraintLayout.. I don't have time to figure it out.

Juan Mendez
  • 2,658
  • 1
  • 27
  • 23