Android how do I zoom and scroll a bitmap which is created on the fly -


in application, i'm using following code holding map downloaded server.

<?xml version="1.0" encoding="utf-8"?> 

    <scrollview android:id="@+id/scrollview1"          android:layout_height="fill_parent"          android:layout_width="fill_parent"         android:layout_gravity="center"         android:layout_weight="1.0">          <imageview android:id="@+id/mapimageview"              android:layout_height="wrap_content"               android:layout_centerinparent="true"             android:layout_width="wrap_content"                              android:scaletype="center"/>      </scrollview> 

currently, can scroll image , down only. need have ability scroll image directions , zoom in , out. how can done? thanks, eyal.

there's simple imageviewtouch sephiroto made based on gallery application code : http://blog.sephiroth.it/2011/04/04/imageview-zoom-and-scroll/

i use in project , works perfectly, pinch-to-zoom , might want. default, when set image it, image scaled down fit screen.

edit : if want prevent automatic image resize, can change imageviewtouchbase.getproperbasematrix method following :

protected void getproperbasematrix(rotatebitmap bitmap, matrix matrix) {     float viewwidth = getwidth();     float viewheight = getheight();     float w = bitmap.getwidth();     float h = bitmap.getheight();     matrix.reset();     matrix.postconcat(bitmap.getrotatematrix());     matrix.posttranslate((viewwidth - w) / 2, (viewheight - h) / 2); } 

this should center image without resizing it.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -