I want to make this kind of arc square border in android. The idea is to set border of the image and only inside picture will show up like the mask. outer picture will be cropped or won't be displayed
I have tried many ways but not able to solve this issue.
Any help would be appreciated!
You can draw that piece by piece using drawLine() and drawArc() functions from the Canvas.
You can check how to use this here.
Try this
You can achieve it by Canvas.
Please go through to draw the shape you want
You can use the library android-shape-imageview
<com.github.siyamed.shapeimageview.mask.PorterShapeImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:siShape="#drawable/shape_bg"
android:src="#drawable/face"
app:siSquare="true"/>
Output on using Library looks like
You can get different shapes by replacing siShape in ImageView
Related
I need to create a chart like this picture bellow in Android.
and I am already aware of MPAndroidChart and AndroidHelloCharts libraries. but none of them are capable of drawing such thing.
do you know any way to create a chart like this?
please explain and at least suggest me some tutorials or articles that are related to what I am about to do.
thank you
Its actually pretty simple to create your own bar chart.
First you need to use drawRect to draw a rectangle.
And then drawText to draw text below the rectangle.
You may have noticed that both methods take a paint object as the parameter , you can think of the paint object like a brush. So you set the color to the brush and draw different elements.
I have written about it
here
I am creating an image painting app in libgdx where user would touch the portion of the image. e.g If the user touch the wheels of a car that should turn into the selected color.
I don't really know how to specify the custom area around the touch. That can be a wheel, a door which are not always rectangle and circle. I just need an idea to do it. Whether libgdx pixelmap can achive this. I have to paint the image inside the border line of the touch region. I hope my problem is clearly stated.
I woule really appreciate for your time for giving the answers. Thanks in advance
I think you want to look at flood fill algorithms. I don't think there is any built-in support for this in libGDX, but you should be able to implement your own flood fill on a libGDX pixmap.
The question is about java applet programming
I used a java applet to draw an image in the paint method using the following code:
g.draw(Myimage,0,0,this);
The image was drawn on the screen, But what i want to do is to be able to change the position of this image without clearing the screen and without drawing blank image in the previous position of the image..
Thanks in advance.
You can simply draw another image in other place. Just change the parameters in your code. For more details about graphics object follow the link. http://docs.oracle.com/javase/1.4.2/docs/api/java/awt/Graphics.html
Other wise why dont you simply extend GraphicsProgram class provided by acm. It has a move function which will exactly do what you want to do. Check out the link.
http://jtf.acm.org/rationale/graphics-package.html
Hope this helps.
But what i want to do is to be able to change the position of this image without clearing the screen and without drawing blank image in the previous position of the image..
Then use a JLabel. When you want to move the label you use the setLocation() method. The RepaintManager will repaint the location where the label was and then paint the label in its new location so you don't have to worry about calculating the area affected by the move.
I have a background image that is white and semi-transparent. This is used as a text container so you can differentiate between the background image and text.
Currently I am using an image that is a white rectangle with rounded corners, but of course when using this on different screen sizes the image is distorted, not massively or that noticeably, but would it be better or possible to draw this image with a canvas?
If it is possible would it slow down the app considerably?
UPDATE:
Thank you #jkhouw1 I have looked into 9 patch images and this seems very suitable. I am still interested in knowing the benefit of canvas against images, but if you post something as an answer I will accept it. Thank you.
use a nine patch is a graphic that android can scale appropriately. see here: http://developer.android.com/guide/developing/tools/draw9patch.html
and here http://www.higherpass.com/Android/Tutorials/Android-9-Patch-Scaled-Png-Image-Guide/
Haven't tried this yet, but I think this should be possible by defining a shape drawable. You can define round corners and you can make it semi-transparent by defining the color with alpha-value, for example #80FF0000 should be semi-transparent red.
I assume this would be a good solution both in terms of compatibility and performance.
I am trying to use JXMapViewer (from swingx-ws) with Open Street Maps. I was wondering if it would be possible to display the map tiles in the JXMapViewer based on heading up, rather than on North up. For example, the normal car GPS navigation systems let you do that.
I've looked through the documentation and there doesn't seem to be a straightforward way to do this. Is there something else that accomplish this, besides JXMapViewer?
Nevermind, I found a solution. Here is how I did it(if anybody is interested) :
I subclassed JXMapViewer, and overrode the paint method.
In the paint method contents of the JPanel are converted to a BufferedImage which is then rotated according to an angle and then painted on top of the panel.
so super.paint()-> BufferedImage-> apply an affineTransformation to it-> draw the new Image.
Of course, you would also need to override the convertGeoPositionToPoint and convertPointToGeoPosition methods taking into account the fact that the image is rotated.