Reputation: 3329
i want to set image on center when i apply properties like this.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainContainerDialog"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/color_screen_bg" >
<Button
android:id="@+id/btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/btn_login_selector"
android:padding="10dp"
android:text="@string/title_cancel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white" />
<ImageView
android:id="@+id/ivProductImageDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix"
android:padding="10dp"
android:layout_above="@+id/btnCancel"
android:src="@drawable/ic_app_bg_logo" />
</RelativeLayout>
but my image view always start upper left corner like below images.
i want this image view in center and then apply pinch zoom on this image view.
Upvotes: 0
Views: 1375
Reputation:
<ImageView
android:id="@+id/ivProductImageDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix"
android:padding="10dp"
android:layout_above="@+id/btnCancel"
android:src="@drawable/ic_app_bg_logo"
android:layout_gravity="center_vertical|center_horizontal"/*The ImageView is Centered by X,Y*/ />
Upvotes: 0
Reputation: 3359
Try this:
Use : RelativeLayout, use: android:layout_centerInParent="true"
.
or
android:layout_gravity="center"
to your ImageView
or
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/btnCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/btn_login_selector"
android:padding="10dp"
android:text="@string/title_cancel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/white" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<ImageView
android:id="@+id/ivProductImageDisplay"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scaleType="matrix"
android:padding="10dp"
android:layout_above="@+id/btnCancel"
android:scaleType="centerInside"
android:src="@drawable/ic_app_bg_logo" />
</LinearLayout>
</LinearLayout>
Upvotes: 0