How to draw a mask (circle) over an Android webview? - android

I have three weeks into Android development (newbie). Is it possible to draw a mask over a webview so that the webview looks like its a circle? My webview is showing google map (dragable). I want that map in the app to look like its a circle, instead of a rectangle that is filling the entire Layout.

In general, yes. But your webview will be unaware of the mask, so you might run into problems with the mask covering parts of the UI. I don't know about the Google Maps web API, but the Android API lets you set padding to move the controls and Google logo away from the edges.
You can create a custom View in which onDraw(Canvas) instructs some other View to draw into a bitmap, then applies a mask to the bitmap and draws it on the output Canvas. To make your webview appear circular, you'd place the custom view on top of the webview, and configure the custom view to use the view below the webview for drawing. This would create the appearance of a hole through the webview.
Shameless plug: I published a MaskView that does exactly this.

Related

How can I draw an rectangle in a android webview?

I want to load an external web page (it can be any website) in my android app within an webview. I then want to draw a rectangle around a specific text or an image.
I have the css coordinates where I want to draw the rectangle and of its size. I don't want to change the css layout of the page, only overlay the page with this rectangle.
Then I want to automatically zoom in on the page to the area marked with the rectangle.
Is this possible?
If yes, how?
Thanks in advance!

Android making scale (ruler) on screen

In my application I want to create a ruler to measure length. I have gone through some ruler application in google store. I want to achieve somewhat as shown in the picture.
So my question is how do I draw this marking as per users mobile screen configuration. Is it using using some drawable image or some drawing on canvas.
I am new to android development. Also that the ruler when dragged downward marking and numbering move. So how to achieve that thing.
These kind of things that requires programmatical access to the data is mostly done using 'drawing to the canvas', which in this case is a window spawned by a service.
You should look into overlay activity implementations such as bubbles for android, which lets you peek into the way this is usually achieved, which is by creating a service that adds a window to the system that draws this, from there you can get the screen details, width and height to draw the ruler with.
Inside the spawned window you can add your own subclass of a view that implements the onDraw method in such a way that the ruler is drawn on the canvas.

Create draggable edge point on imageView

I want to create a resize feature of my application but I cannot find a sample implementation of it. Many tutorials offers pinch to zoom.
My problem now is how to implement draggable edges to resize the image just like in ordinary image editor. Do you have any idea how to do this? Just like putting circles/points on the 4 corners of the ImageView like the sample image below.
Is it possible to use the crop library of android to have draggable image?
You can draw the control point, and handle all festure in this point
last month i develop a Android handwritting note app. In this app, i inherit View, and control View.onDraw directly. I draw the image and all control indicator in onDraw, and handle screen touch within the scope of the screen.
This app isn't accomplished, it become a opensource project, you can see the source at https://bitbucket.org/gd920129/white-board/

How to draw on a video view in android?

I am trying to create and android application that allows the user to draw a circle or other shape on a video feed to highlight a region of interest. Is it possible to draw directly on the video view or even overlay a canvas on top of the video view? I am using Eclipse.
Maybe you could start from creating some bitmap (transparent background) over the video and draw on it? Another idea is to create transparent fragment, it will be probably easier to do and you will have more control over it.
Please search here:
How do you create a transparent demo screen for an Android app?

Android App Intro with Overlay

I would like to make a quick intro to my app for new users. The intro would highlight features in the ui and explain the functions, similar to the Slices(see screen shot below) and Youtube app.
I imagine this involves a transparent overlay of the entire screen and then getting the location of the view on the screen so it can be circled or highlighted in the overlay. I am not sure how to go about making one section of the overlay not transparent. Any ideas?
To get the effect you want in the simplest way possible you would want to create new assets and have them overlay your opaque background. This creates the illusion of the effect with out the pain of getting the dynamic way to work correctly on all devices.
The dynamic way to punch holes in a layer involves creating a custom view, overriding the dispatchDraw method and applying a custom mask to the canvas. For punching holes in the canvas, your custom paint object would be created like this:
maskPaint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
Compatibility isn't great with this so I'd recommend faking it.
Just add a new View() and set the background to black with 70% alpha. Make sure the Parent ViewGroup of your Fragment is a Relativelayout and the call bringChildToFront(MyHighlightedView).
overlay=new View();
overlay.setBackgroundColor(#*BLACKWITHALPHAVALUE*);
getView().addView(overlay, new LayoutParams(MATCH_PARENT,MATCH_PARENT);
getView().bringChildToFront(overlay);
getView().bringChildToFront(MyHighlightedView);

Categories

Resources