Ivan
Ivan

Reputation: 4234

How can I align an image inside an ImageView to the bottom of the ImageView?

I want the drawable inside my ImageView to be shown aligned to the bottom (of the Imageview), and not centered.

Is it possible to do that?

Upvotes: 14

Views: 11675

Answers (4)

If you have SVG you can open it in https://boxy-svg.com/app or any other online svg editor

Align Image Bottom.

enter image description here

Upvotes: 0

DragonT
DragonT

Reputation: 511

You can wrap the ImageView inside a FrameLayout and align using android:layout_gravity like this:

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal|bottom"
            android:src="@drawable/img_select_profile" />
</FrameLayout>

Upvotes: 2

Swayam
Swayam

Reputation: 16364

Maybe this is too late, but even I ran into the same problem today and fixed it by using the following snippet.

All the alignment/scaling options are in the scaleType attribute.

Now, if you want to align the image with the beginning of the ImageView, use android:scaleType="fitStart".

Similarly, android:scaleType="fitEnd" to align it with the bottom of the ImageView.

Upvotes: 48

Pocket Universe
Pocket Universe

Reputation: 1438

You'll have to set the weight of it to 1 or set its alignment to bottom.

http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html

Upvotes: -2

Related Questions