Note that there are some explanatory texts on larger screens.

plurals
  1. POImageView doesn't fill the height of its layout
    text
    copied!<p>I wish to add an <code>ImageView</code> inside a <code>ListView</code>. I would like the image to fill the layout without distorsion (basically, fill the height and adapt its width).</p> <p>This is what I get now: </p> <p><img src="https://i.stack.imgur.com/MlnbW.jpg" alt="enter image description here"></p> <p>I have put a grey background to the <code>ImageView</code> to make it easier to see. In red, it's the size I wish to get.</p> <p>Here is my code: </p> <p><strong>Project_form.xml</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"&gt; &lt;TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/name_project" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:padding="3dp" android:layout_alignParentLeft="true" android:textAppearance="?android:attr/textAppearanceMedium" android:textSize="25dp" &gt; &lt;/TextView&gt; &lt;Button android:id="@+id/button_project" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/btn_custom" android:layout_centerVertical="true" android:focusable="false" android:focusableInTouchMode="false" android:layout_alignParentRight="true" android:padding="3dp" android:text=" details " android:textSize="20dp" android:visibility="invisible" /&gt; &lt;ImageView android:id="@+id/imagesstep" android:layout_width="wrap_content" android:layout_height="fill_parent" android:background="@color/grey" android:adjustViewBounds="false" android:layout_centerVertical="true" android:padding="3dp" android:layout_alignParentRight="true" android:visibility="invisible" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p><strong>method getView() of my <code>Adapter</code></strong> : </p> <pre><code>@Override public View getView(int position, View convertView, ViewGroup parent) { View row = convertView; if (row==null) { LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); row = inflater.inflate(R.layout.project_form, parent, false); } TextView text = (TextView) row.findViewById(R.id.name_project); text.setText(this.objects[position].getName()); int IDImage=this.objects[position].getIDImage(); int IDPlay = this.objects[position].getIDPlay(); text.setCompoundDrawablesWithIntrinsicBounds(IDImage, 0, 0, 0); text.setCompoundDrawablePadding(7); ImageView image = (ImageView) row.findViewById(R.id.imagesstep); image.setVisibility(View.VISIBLE); image.setImageResource(IDPlay); if (position == selectedPosition) { row.setBackgroundColor(Color.parseColor("#8000ff00")); } else { row.setBackgroundColor(Color.TRANSPARENT); } return row; } </code></pre> <p>I tried to play with different parameters such as <code>ScaleType</code>, android:adjustViewBounds and layout_width but the height of my image never changed. I also tried to do it programatically (something like image.setMinHeight(parent.getHeight()) but it failed too.</p> <p>Could anyone point me out what is going wrong?</p> <p>Many thanks</p>
 

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