I have the following layout (it is complex but I have to put it all) ; I have 3 LinearLayouts, horizontal with a tiled png as background : 2 must be placed in the top of the screen and the last in the bottom of the screen. Between I have to put a widget gallery.
I want the 3 LinearLayouts to take the height of the png used for their backgrounds (it is ok for the 2 first but not for the last which is resized) and the gallery take the remaining size of the screen.
I cannot understand why that third LinearLayout is resized.
Thanks a lot in advance for your help. I put 2 pictures after the code to understand the situation.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<!-- THE FOLLOWING LAYOUT SHALL TAKE THE HEIGHT OF THE IMAGE USED FOR BACKGROUND
=> IT IS OK -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_title"
android:gravity="center_horizontal">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/home_title"
android:textColor="@color/white"
android:gravity="center"
android:textSize="20sp"/>
</LinearLayout>
<!-- THE FOLLOWING LAYOUT SHALL TAKE THE HEIGHT OF THE IMAGE USED FOR BACKGROUND
=> IT IS OK -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_channel_title">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/channels_frameLayout">
<HorizontalScrollView
android:id="@+id/channel_scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/channel_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
</FrameLayout>
</LinearLayout>
<!-- THE FOLLOWING LAYOUT SHALL TAKE THE REMAINING HEIGHT OF THE SCREEN -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
android:id="@+id/description_frameLayout">
<Gallery xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gallery"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
/>
</LinearLayout>
<!-- THE FOLLOWING LAYOUT SHALL BE PLACED ON THE BOTTOM OF THE SCREEN
AND TAKE THE HEIGHT OF THE IMAGE USED FOR BACKGROUND
=> IT IS NOK, THE LAYOUT IS RESIZED IN HEIGHT -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/bg_description"
android:id="@+id/description_layout"
android:gravity="bottom">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="left"
android:id="@+id/texts">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/orange"/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"/>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="right"
android:id="@+id/btns">
<ImageButton
android:id="@+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/btn_info" />
<ImageButton
android:id="@+id/favorite"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/btn_favorite" />
</LinearLayout>
</LinearLayout>


I finally decide to move on and find an other way to solve my problem.
Everything is now done with xml configuration.
This is the layout containing the buttons in the bottom part of the screen :
And here is the bg_description.xml :
Everything is perfect now. The background is well displayed, the rendering is better than with the png and the there are not resizing problems anymore.
Tiled backgrounds are good but for simple use cases like this one, we have to consider better and simpliest solutions through the xml configuration.