I am looking to make an ImageView that I can manipulate with touch (translate, scale and rotate). I currently have one that uses ScaleType.MATRIX and can be translated and scaled. I would like to be able to wrap this ImageView with a border, and put ImageButton objects in the corners to act as a 'close' and 'scale/rotate' button. Much like in the image below (taken from the Aviary app):
I cannot figure out where to start with this. In order to manipulate the ImageView I need to set the view to MATCH_PARENT, and use a Matrix to manipulate the drawable within it. But then how am I supposed to wrap the drawable in a border?
Or am I supposed to manipulate the ImageView directly instead of the drawable? If so, how would I go about doing that with a Matrix?
Create a frame layout and add the four buttons on it the add the frame to your layout. Use the onclick of that buttons to create different functions you mention.
Related
Is it possible to blend two different views in different modes like Multiply, Add etc.
I have two views one is a RelativeLayout matching parent shape with a background image. Another one is ImageView (solid colored custom shape) inside the parent RelativeLayout.
I need to blend top ImageView to the background image in Multiply mode.
any kind of help would be appreciable.
I have a blueprint image in my app. The user will be able to click on some pre-established points and after they click on this point, a dialog will show some information.
My question is how I add the specific points in my ImageView Blueprint and the click function on these points?
EDIT 08/08/2014
My ImageView now has pinch zoom and the app will have more than 1 blueprint.
Thanks and regards!
You could go about this multiple ways. If your blueprint is full screen on the users device then you could create your own custom layout to encapsulate the imageview and override the ViewGroup's onDraw an onTouch methods to add your points. Then you could have a method like
public void addPoints(float[] points) { // do something here }
Another option is to extend the ImageView itself and make your own custom imageview and then again override onDraw and overlay the points ontop of the image. YOu can set the bitmap (your blueprint) as the background and then drop ontop of that. You would have to figure out where the specific points are though depending on the size of your image and the device, unless you set the size to be pixel density independent.
The first thing that comes to mind is you could use RelativeLayout in the XML file. This allows you to layer elements on top of one another if you so choose. You could use this to position invisible buttons above the image.
With RelativeLayout, each button could be positioned using its margin attributes, and it should be fairly simple to make the button invisible by assigning the transparent color for its background and providing no text.
I want to make application which will have background and some picture with alpha channel in front. Between them i want to draw bitmap/animation.
How can i do it ?
That is easy. You can use FrameLayout as the root layout and set a background to it. Then add two more LinearLayouts which fill the screen. In the first you may add your animated views like ImageView, while in the second you can insert an ImageView or ImageButton with a transparent image in it.
There are many other ways to do this like using a custom view for your animated layer etc. Check my example here: How can I use the animation framework inside the canvas?
Hi, I want to develop a form on a rectangle.
I have designed a rectangle using a bitmap and an image, but how do I add edit texts and buttons onto that?
Please provide some good guidelines.
You can create a layout inside your main layout with background as your bitmap image.
Then put your widgets inside this inner layout.
When you place your widgets be sure that it is coming correctly in all screen sizes.
For that try to avoid manually setting pixel values.
Use dp instead.
Also use layout properties of relative layout.
I wounder how its possible to make a shape like the example, with round corners and padding from the screen borders, and also put text inside, how is this possible?
You can either use image buttons that contain image background with e.g. rounded corners or draw your own shapes, Android Shapes.
Using ImageButton you can define hover, focus and default state of a button and appy a background image to each state.
Here is a small code example with source, tutorial.