Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I get ImageView to scale an image and align top right?
    primarykey
    data
    text
    <p>I've spent 3 hours trying to get this to work without success so heopfully someone here can help.</p> <p>I have a FrameLayout that is being loaded via inflate from an XML file and in it I have the following layout: <code></p> <pre><code> &lt;LinearLayout android:layout_width="0dip" android:layout_height="fill_parent" android:layout_weight="1" android:orientation="vertical" &gt; &lt;ImageView android:id="@+id/element_image" android:layout_width="wrap_content" android:layout_height="0dip" android:layout_weight="1" android:layout_marginBottom="10dip" android:layout_marginLeft="10dip" android:scaleType="fitStart" android:background="#888888" &gt; &lt;/ImageView&gt; &lt;Button android:id="@+id/element_button" style="@style/Button" android:layout_gravity="right" android:text="@string/element_button_label" /&gt; &lt;/LinearLayout&gt; </code></pre> <p></code></p> <p>I have an image loaded from a BLOB which I want to display in this ImageView. In the GalleryAdaptor I load the image like this:</p> <pre><code> ImageView image = (ImageView) v.findViewById(R.id.element_image); byte [] bitmapData = cursor.getBlob(4); Bitmap bitmap = BitmapFactory.decodeByteArray(bitmapData, 0, bitmapData.length); image.setImageBitmap(bitmap); </code></pre> <p>When I use android:scaleType="fitStart" in the layout above the image is not scaled to the height or width of the ImageView but is about a third of it's width (which I can see from the grey background I have given it) and is centered.</p> <p>If I use android:scaleType="fitXY" the image height is scaled but the width is not. Again the image is centered.</p> <p>Can someone give me some pointers on:</p> <ol> <li>How to get the image to scale both height and width wise</li> <li>How to align the image top right</li> </ol>
    singulars
    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.
    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