Skip to content Skip to sidebar Skip to footer

How To Set Gravity (or Margins) Of Imageview Using Code?

I want to add ImageView to FrameLayout with Gravity or margins. but FramLayout and ImageView has no method about that(Actually, I can't found that). Reason that selects Framelayout

Solution 1:

Try:

image.setLayoutParams(new FrameLayout.LayoutParams(width, height, gravity));

More info:

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

Post a Comment for "How To Set Gravity (or Margins) Of Imageview Using Code?"