Hi all below is the code to set Imageview center of the layout
XML code:
In
LinearLayout
, use: android:layout_gravity="center"
.
In
RelativeLayout
, use: android:layout_centerInParent="true"
.
Via programmer:
Imageview.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.WRAP_CONTENT));
ImageView.setGravity(Gravity.CENTER)