Note that there are some explanatory texts on larger screens.

plurals
  1. POImageView in android XML layout with layout_height="wrap_content" has padding top & bottom
    primarykey
    data
    text
    <p>I have a vertical LinearLayout containing an ImageView and a few other layouts and views.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:contentDescription="@string/banner_alt" android:src="@drawable/banner_portrait" /&gt; &lt;TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/main_search" android:gravity="center" android:textStyle="bold" /&gt; &lt;LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;Spinner android:id="@+id/search_city_spinner" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:prompt="@string/search_city_prompt" android:entries="@array/search_city_array" /&gt; &lt;Spinner android:id="@+id/search_area_spinner" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:prompt="@string/search_area_prompt" android:entries="@array/search_area_array" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content" &gt; &lt;Spinner android:id="@+id/search_rooms_spinner" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:prompt="@string/search_rooms_prompt" android:entries="@array/search_rooms_array" /&gt; &lt;Spinner android:id="@+id/search_min_spinner" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:prompt="@string/search_min_prompt" android:entries="@array/search_min_array" /&gt; &lt;Spinner android:id="@+id/search_max_spinner" android:layout_width="0px" android:layout_height="wrap_content" android:layout_weight="1" android:prompt="@string/search_max_prompt" android:entries="@array/search_max_array" /&gt; &lt;/LinearLayout&gt; &lt;Button android:id="@+id/saearch_button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/search_button" android:onClick="searchButton" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>My problem is that when the activity is displayed, the ImageView has a padding at the top &amp; bottom. I've confirmed it is the ImageView (by setting a background colour on the ImageView).</p> <p>The image is 450x450px. Setting the height manually to 450px produces the desired effect (no padding), and setting it to 450dp produces the same effect as using wrap_content.</p> <p>It seems that android is taking the height of the image (450px) and setting the height of the ImageView to the same value, but in dp.</p> <p>Any ideas as to what I can do to fix this? I don't want to use absolute values as I'll be providing different images for different screen densities.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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