drag n drop textview in android

I want to drag n drop the text view on image in android 2.X

please , look at this image below.
alt text

  • Opening InfoWindow automatically when adding marker Google Maps v2 Android
  • Android : Layout with Rounded drop shadow
  • Will Samsung support Google's fingerprint API from Marshmallow?
  • Activity not visible in Recents when app is in background
  • How to set ringtone in Android from my activity?
  • Google Play says my APK built with Android Studio Build->Generate Signed APK is debuggable
  • Here, “Blue” color represents the ViewGrop , “White” is ImageView and the image is set on the ImageView.
    the text written “Fashion” is a TextView.This is how i have implement the structure. Now i want to allow the user to select the TextView and drag it to any part of the image and then drop it over the image at desired position.

    As of now for a reference i tried to refer the following url but whenever i use TextView instead of Button things are getting abnormal.

    link text

    Can anyone give me the road map or example to get it done ?

    Related posts:

    Does android:scaleType=“fitCenter” only work with fix Layout_width and Layout_he...
    Custom textview with rotate, zoom in,zoom out and move on touch in android?
    Android center custom view in actionbar
    broadcast receiver won't receive camera event
    createNewFile - open failed: ENOENT (No such file or directory)
    Android CardView with weird border when transparent
  • Android localization values-** folder names
  • screen styling when virtual keyboard is active
  • Creating a new Icon Set in Android Studio?
  • Get The Measures of Popup Window
  • How to change the android emulator RAM size from the command line?
  • How to programmatically log out from Facebook SDK 3.0 without using Facebook login/logout button?
  • One Solution collect form web for “drag n drop textview in android”

    Instead, try getting your ImageView as a canvas to draw into.

    ImageView CanvasView = (ImageView) findViewById(R.id.fashion_pic)

    From here you can create your own Bitmap and re-draw it after a TouchEvent. The following snippet contains a necessary work-around for a bug in 2.1 (or 2.2, I can’t remember):

    public void redrawImage() {
        Bitmap bm = BitmapFactory.decodeResource(getResources(), R.drawable.fashion_pic);
        Bitmap proxy = Bitmap.createBitmap(bm.getWidth(), bm.getHeight(), Config.ARGB_8888);
        Canvas c = new Canvas(proxy);
        //Here, we draw the background image.
        c.drawBitmap(bm, new Matrix(), null);
        //Here, we draw the text where the user last touched.
        c.drawText("Fashion", someGlobalXvariable, someGlobalYvariable, somePaint);

    Here, you have created a canvas which already has your picture as the background and paints text at an x and y variable. Now, just set an OnTouchListener:

    CanvasView.setOnTouchListener( new OnTouchListener(){
        public boolean onTouch(View v, MotionEvent e) {
            someGlobalXvariable = e.getX();
            someGlobalYvariable = e.getY();
            return true;

    As you can see, the listener automatically updates your image when it is touched, and the text will follow the user’s finger. Since you’re using a Bitmap as your canvas, you can also add support for saving/loading an image if your app wants to have that kind of functionality.

    Edit: It may be more performance-friendly if you move lines 1-3 from redrawImage() and place them elsewhere, setting those objects as global objects. I’ll let you tinker with that.

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.