androidxmlandroid-imageviewtouchimageview

TouchImageView not showing in xml


I am using TouchImageView for zooming in/out of my picture. However, after I've done adding TouchImageView.java and proceed to create a customview in xml, it didn't show up. Below is my xml file:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cast_expanded_controller_background_color"
android:id="@+id/Rlay">

<com.example.zhen.myggwpapp.TouchImageView
    android:layout_height="350dp"
    android:id="@+id/iv_preview_image"
    android:layout_width="match_parent"
    android:scaleType="matrix"
    android:layout_centerVertical="true"
    android:layout_alignParentStart="true" /></RelativeLayout>

TouchImageView in xml showing only blue dot


Solution

  • Try to add a android:src:@drawable/some_image inside your ImageView, or add some background to see the width and height of it. android:background="@color/some_color"

      <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:orientation="vertical" android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="@color/color_white"
            android:id="@+id/Rlay">
    
            <com.example.zhen.myggwpapp.TouchImageView
                android:layout_height="350dp"
                android:background="@color/color_black"
                android:id="@+id/iv_preview_image"
                android:src="@drawable/some_image"
                android:layout_width="match_parent"
                android:scaleType="matrix"
                android:layout_centerVertical="true"
                android:layout_alignParentStart="true" />
    
        </RelativeLayout>