Question

Can any one help me to know how to add TextField on ImageView Dynamically. And drag them to any position on that ImageView as we want...

Was it helpful?

Solution

I think the Drag and Drop Blog will help you. In which i have dragged image as well as text both on touch event of fingure.

Check out the Code HERE

OTHER TIPS

You can create a relative layout as container of your imageView (or directly set your image as relativeLayout background) like in this manner:

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/relativeLayout">
        <ImageView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:id="@+id/imageView"
            android:src="@drawable/your_image"
            android:layout_centerHorizontal="true" />
<RelativeLayout>

and programatically, you get your imageView and add the textView to that:

RelativeLayout relativeLayout = (relativeLayout) findViewById(R.id.relativeLayout);
ImageView iv_myImage = (ImageView) findViewById(R.id.imageView);
// Create new textView
TextView textView = new TextView(context);
// Here set style on textView
// Finally add textView to imageView
relativeLayout.addView(textView);

About drag and drop there's plenty topics about.. see http://www.techrepublic.com/blog/software-engineer/try-androids-useful-drag-and-drop-api/

drag and drop textview

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top