Note that there are some explanatory texts on larger screens.

plurals
  1. POFitting ImageView and TextView in a layout
    text
    copied!<p>I have horizontal ListView with with following item:</p> <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/thumbnail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingLeft="5dp" android:paddingRight="5dp" android:src="@drawable/a" /&gt; &lt;TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="Title" android:textColor="#FFFFFF" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>This is basically thumbnail and some text beneath it. The problem is - when this item is displayed in ListView the text at bottom is only partially visible - bottom part disappears. Looks like ImageView is not scaling to fit TextView.</p> <p>But if you put TextView above ImageView everything looks fine - ImageView is scaled down and text fits perfectly. So..why?</p> <p>Let me illustrate:</p> <p>TextView at bottom</p> <p><img src="https://i.stack.imgur.com/CC4qu.png" alt="TextView at bottom"></p> <p>TextView at top (images scaled perfectly)</p> <p><img src="https://i.stack.imgur.com/btFOZ.png" alt="TextView at top"></p> <p>And as requested main.xml:</p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" android:weightSum="100" &gt; &lt;LinearLayout android:id="@+id/linearLayout0" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="10" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Top Activity Header" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="90" android:orientation="vertical" android:weightSum="100" &gt; &lt;LinearLayout android:background="#6056CC" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="30" android:orientation="vertical" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Top" android:textAppearance="?android:attr/textAppearanceLarge" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="0dp" android:layout_weight="40" &gt; &lt;test.name.Coverflow android:id="@+id/coverflow" android:layout_width="wrap_content" android:layout_height="fill_parent" /&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:background="#BF5E76" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="30" android:orientation="vertical" &gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&gt; &lt;LinearLayout android:layout_height="65dp" android:id="@+id/linearLayout2" style="@style/TabPanel"&gt; &lt;/LinearLayout&gt; &lt;/LinearLayout&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