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

  • Couldn't expand RemoteViews: MediaSessionCompat and NotificationCompat.MediaStyle on HUAWEI devices
  • Custom tabs in android
  • Cordova fingerprint authentication on server
  • How to use googletest for testing C++ code that calls into java on android?
  • Android get a cursor only with contacts that have an email listed >android 2.0
  • Android Notification intent to clear it self
  • 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:

    Android Studio - Failed to find style 'textViewStyle'
    Questions about Android application update
    How do you use an OnClickListener in a recycler view?
    android:drawableLeft margin and/or padding
    Is this custom CursorAdapter for a ListView properly coded for Android?
    Assets folder in Android Studio Unit Test
  • Android: how to center view within column of TableLayout?
  • Google Inbox like RecyclerView item open animation
  • Android and supporting multiple screens layouts
  • Google Analytics in Android app - dealing with multiple activities
  • What is the default path of debug.keystore on Mac?
  • Merging cells in Excel using Apache POI
  • 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.