2016-12-16 23 views
0

在Android上運行示例使用PinchZoom我發現以下example。我能夠編寫一個工作示例代碼,顯示示例中的視圖 - 但它全是白色的!我如何在這個例子中使用實際的圖像?如何在Android上運行捏放大示例?

我試圖在活動的XML如下:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#FFFFFF" 
    android:orientation="vertical" > 

    <com.example.alexander.capycoding_pinchzoom.CanvasView 
     android:id="@+id/signature_canvas" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:src="@drawable/image" 
     android:textColor="#FFFFFF" /> 
</FrameLayout> 

使用一個實際的非白色圖像,但它不能正常工作。 (我也將班級從ZoomableImageView更名爲CanvasView)。

也許有另一個/更好的例子,如何使在Android的Canvas/Bitmap PinchZoom可行?

+0

實際工作的更簡單的示例:http://stackoverflow.com/questions/5216658/pinch-zoom-for-custom-view – Alex

回答

0

您正在xml.use圖片中使用默認圖片,並通過簡單地把xml不能單獨執行action.i建議使用庫文件進行縮放,然後創建一個縮放規格的類