Alrighty, lets tackle them one by one:
Is EditText the right control for this?
Sure, unless you want to create an application just like MS word, this will work perfectly.
something like multiple Edit Text can be used as different pages on word and you can specify a length an width with the usual XML attributes for each "page", separate them by a view
to get the ending of page and start of a new page mechanism.
now to achieve an adding of a picture with the cursor, you can just create a context menu and add that image to your layout programmatically, ending your edit text
, creating an image view
and continuing with another edit text
, lets see how this can be done:
first your context menu:
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.context_menu, menu);
if(item.getTitle().equals("Insert Image") ){
InsertImage(Uri imageUri);
}
}
How do I invoke the context menu from where the cursor is?
How do I paste the image where the cursor is?
you need to implement something called View.OnCreateContextMenuListener
which is done with a long click
at wherever you press, so as you will see you will either have to implement another method to get where the cursor is and then split your edit text into two different edit text
and insert your image or you will have to always have the image under the text view as your picture suggests
Secondly, when the context menu is created we can call a method call it "InsertImage" with a argument of Uri passed from the menuInflater or defined as a variable in your class to create an ImageView
to be after your EditText
assuming your parent layout is a linear layout :
LinearLayout LLayout = findViewById(R.id.linearLayout);
ImageView mImageView = new ImageView(this);
mImageView.setLayoutParams(new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
LLayout.addView(mImageView);
And after the method "InsertImage
" is done you can return a boolean
to give you true if image is uploaded or if it is not, if it is, then you will create another method to start a new edit Text
exactly like the imageView
but if it is not uploaded then you can just call removeView
same way as addView