Thursday, March 21, 2013

e. How to give a zoomable picture in an Application

Zoomable pictures are only supported in Webview and Mapview. So first we have to create a Webview layout with zoom controls in it.
First copy the picture in to the assets folder
Then, Copy the following code in to activity_main.xml file

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MapActivity" >
       
       
        <ZoomControls
            android:id="@+id/zoomControls1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentRight="true"
            android:layout_marginBottom="52dp"
            android:layout_marginRight="20dp" />

        <WebView
            android:id="@+id/webView1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"           
            android:layout_alignParentTop="true"
             />

</RelativeLayout>


Now vopy the following code in the oncreate method,in ActivityMain.Java file

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_map);
        // Show the Up button in the action bar.
        //getActionBar().setDisplayHomeAsUpEnabled(true);
       
        WebView WV = (WebView)findViewById (R.id.webView1);
        WV.loadUrl("file:///android_asset/kerala.jpg");
        WV.getSettings().setBuiltInZoomControls(true);
        WV.getSettings().setSupportZoom(true);
         
    }


You are done.Dont forget to replace the kerala.jpg file name with your filename of picture. Just run the application yoiu will find the picture as zoomable.

9 comments:

  1. Zoomable picture is good fun and android application developers can develop this according to the requirement. This xml file help for the same one. Great one.

    ReplyDelete
  2. Thanks for sharing this information. your blog is good and I got so much knowledge. Please visit https://goo.gl/Za2Qf4

    ReplyDelete
  3. hello,
    i just want to say that you have clearly mention the process very clearly and i also found it is very much easy
    to understand. keep sharing.

    ios app development company in chennai

    ReplyDelete
  4. Great post. I was checking continuously this blog and I am impressed! I enjoyed reading your post. Please continue publishing helpful information like this. I like this type of information and share my opinion with you.Digital Marketing Company in India | Travel Technology Software | Software Development Solutions in India | Web Design Services in India | Mobile App Developer Noida

    ReplyDelete
  5. The using this method cheap essay does not require any special skills for a successful completion. The scalable image easily becomes noticeable thanks to this.

    ReplyDelete
  6. Great share! Thanks for the information. Keep going1

    ReplyDelete

Please give your valuable comments so as to know whether this blog is useful to you.You can also write helpful Android Development Syntax or Shortcuts or Tips.