Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid Crop LinearLayout Background
    text
    copied!<p>In my android app I have a background that is used for sections on the screen (not the entire screen) so I'm trying to apply it to a LinearLayout. The problem is that this is stretching the LinearLayout to the size of the image. I want it to Crop the image. I tried using a bitmap and couldn't get that to work, tried putting my image in an ImageView within a relative layout and couldn't get that to work either. What should my xml look like?</p> <pre><code> &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="clip_vertical" android:background="@drawable/bg_blue_w_pattern"&gt; &lt;RelativeLayout style="@style/menu_layout" local:MvxBind="Click CalculatorsCommand"&gt; &lt;ImageView android:id="@+id/img_calculators" android:src="@drawable/calculators_icon" style="@style/menu_image" /&gt; &lt;TextView android:layout_toRightOf="@+id/img_calculators" style="@style/menu_text" android:text="Calculators" /&gt; &lt;ImageView style="@style/menu_arrow" /&gt; &lt;/RelativeLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>Trying to use an ImageView with scaleType set within a RelativeLayout doesn't work either. The RelativeLayout size is always too large (scaled to the size of the image). What is wrong with this xml?</p> <pre><code> &lt;RelativeLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"&gt; &lt;ImageView android:id="@+id/background" android:src="@drawable/bg_blue_w_pattern" android:layout_width="fill_parent" android:layout_height="wrap_content" android:scaleType="center" android:layout_alignParentTop="true" /&gt; &lt;TextView style="@style/menu_text" android:layout_alignParentTop="true" android:text="Calculators" /&gt; &lt;/RelativeLayout&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload