Saturday 29 December 2012

How to crop an Image in Android?


This is a sample program that launches the camera and crop the captured image.

Check this link to another crop image example.









This is the layout xml.
<strong>activity_main.xml</strong>

[xml]
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="3dp"
        android:text="@string/intro"
        android:textStyle="bold" />

    <Button
        android:id="@+id/capture_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/capture" />

    <ImageView
        android:id="@+id/picture"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:contentDescription="@string/picture" />

</LinearLayout>
[/xml]

Now this is the Main Java File that implements the crop functionality.

Read More from here...

http://www.coderzheaven.com/2012/12/15/crop-image-android/

No comments:

Post a Comment