I am making an app in which a user enters some text and that text has to be displayed on a rectangle on an image(like a notes-stick on the image, it can be dragged on the image and also re-sized). I am very new to android and i really can't find a way to do so in android through books and google.
I have been designing apps using html, in html we could just style a text-box like we want and add it anywhere on the page. But here i am unable to configure the edit-text to do the same. But i am unable to make the edit-text like a notes-stick and to make it draggable and re-sizable dynamically.
I also tried drawing just a rectangle using canvas.drawrect() ... but how to add text to that dynamically is something which i am unable to figure out.
I am not asking for the entire code ..but please guys give me a head-start to the right direction so that i can try things out and try to figure out a way.. Right now i am badly stuck.
The image below shows how the notes-stick should look like...
If you don't need it to be actually drawn on the canvas itself, using an EditText widget and having both it and your image in a RelativeLayout may be the way to go. You can set max height and width of the EditText, or have it wrap the height so it expands with the text, etc. Just make sure that the EditText widget gets added to the RelativeLayout after the image, so it is on top.
Related
I am trying to create an android app for having formations like this one with drag and drop functionality. My challenge is to combine a image view and edit text as a single entity so that they can dragged around and be placed in the appropriate position. How do i approach this? I have tried the following:
Edit text with background image or drawables to the top. The problem is the size of the drawable cannot be altered
Separate imageview and edit text in relative layout. When I drag, only the edit text moves. Not the image.
Please help me solve this problem.
I want to make an app in which I ll show a human body. when we click on any body part the organ name should be displayed with a toast. How will I detect which body part is selected. According to me i ll make small images for every organ. and place those images behind the main image. Is it the right way? How will I draw organs(Bitmaps or png images?).
I think an easier way to do it is to draw shapes or even buttons over your image, and define them as transparent so you don't see them. Then, using onClickListener you can capture what button is clicked and do whatever you want.
Check this for an example
I'd like to create a button for a calculator with normal and secondary text on it. The picture below outlines it pretty succinctly. My main concern is getting the secondary text to scale well on different devices. This makes me think that I want to use a secondary text view, or find some way to use HTML to render the button secondary text in the button.
The problem I'm running into is that I have no idea what the most scalable and robust way of doing this is.
Is it necessary to create a custom button? Or is there some way to get the button's setText() with HTML.fromHTML() to place the secondary text at the top left corner? So far adding more lines makes the button stretch, and adding specific padding for the button doesn't scale to other devices. I assume a background 9 patch image using the secondary text won't work either, as larger buttons won't scale the secondary text.
Anyone have any pointers? Thanks!
I am trying to create a header navigation for my app. I want to get rid of spaces between the buttons, and as I understand it, I need to set images as the background.
My question is whether the images should contain the text on them, or be transparent, and I would just put the text on the buttons by the text field in the layout of that button?
Thanks!
You can have it both ways, but I'd recommend setting the text on the images it saves you space and allows more room for change in case you wanna change a word you dont have to edit the image.
And most importantly you let android auto scale you text to fit screen size( if you set to sp of course )
If I have a custom image can I write over it, will it always write to the center of the button image? Ie will setText on image always right to center of the image provided or do I need to do something to have this effect? Thanks Also is it better to use ImageButton or set Image as background of Button? and write over it that way. I want to use 3d images and write on top of them in black text.
I don't know if there is a preformance difference for using image button of a normal button, but I'd imagine that and image button will work better. Albiet I always just use a normal button and setBackground(...). Also if you want to set the text to always be in the middle, use android:gravity="center" in the layout file.