alexvasilkov / GestureViews

ImageView and FrameLayout with gestures control and position animation
Apache License 2.0
2.38k stars 384 forks source link

how do I center image? #81

Closed angelkoh closed 7 years ago

angelkoh commented 7 years ago

Is it possible to center the loaded image if I am using match_parent for both the Width and Height? Currently, it defaults to the top of the parent. I noticed that portrait images are centered horizontally, but landscape images are not centered vertically.

<com.alexvasilkov.gestures.views.GestureImageView 
                android:id="@+id/view_main_image"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:padding="8dp"  />

setting layout_gravity and gravity don't seem to have any effects.

angelkoh commented 7 years ago

This can be achieved by getController().getSettings().setGravity(Gravity.CENTER);

alexvasilkov commented 7 years ago

Hm, Gravity.CENTER should be default setting, so you don't need to specifically set it unless you already set it to a different value somewhere else.