0

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

rafsanahmad007
  • 23,683
  • 6
  • 47
  • 62
Zhen Jing Heng
  • 109
  • 2
  • 8

2 Answers2

1

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>
Luiz Fernando Salvaterra
  • 4,192
  • 2
  • 24
  • 42
0

In my case, there is something wrong in a method called "fitImageToView." Somewhere in that method, it need to get a float array from value:prevMatrix.

The array is not null. Every set in the array are not null. But there are some NaN/ Not A Number. If you got a NaN, set the value to a correct number (like 0). In the next frame or next time getValue, there won't be any NaN.

Float.isNaN(float f) can help you to detect NaN.

(In my project, TouchImageView can be really old version. This bug may be fixed. In the case... good luck. Nothing I can do.)

hsu.tw
  • 148
  • 2
  • 10