Home > Tricks & Tips > ImageView Alignment Trick

ImageView Alignment Trick

If you pay attention to ImageView when it’s not bounded by a ViewGroup layout, it is ALWAYS aligned in the center of its parent. Seriously, you cannot set any kind of “gravity” to make it change its aligning position.

I have troubled with it this morning, and finally I’ve found one trick through it, apply the attribute “scaleType” with value of “fitStart” then it would be aligned to the left of parent, of “fitEnd” to align to the right of parent. Not a completely perfect solution but it’s a good workaround.


Hope you like it!

Pete Houston

  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: