How to "redraw" single view(Dirty View Only) in Android using canvas? - android

In my sample app i am drawing images on canvas.
Now on touch of any view I use "view.bringToFront(..)" to bring view on top,and invalid selected view.
But here it drawn each view again at place of an single view.
I just want to draw an dirty view here.
Pls let me know how can I handle this,
Similar problem here : Android: How to get a custom view to redraw partially?
Thnx

Related

Invisible views detection on motion event

As i already tried views with motion drag reading Android docs.
I have clearly not saying about basics of it but i want to hide orinvisible view which will be visible when other view which is being dragged or using motion can taken to the hidden orinvisible surface area ?
Set tag of to view and after that when you touch view check tag of that view in MotionEvent.ACTION_DOWN or MotionEvent.ACTION_MOVE and set View.setVisibility(View.INVISIBLE) for other views.
I think it should be easy using transparent color for this View. Even you will use ViewGroup with other elements, you can just create method for updating parameters (like background, color, image, etc.) to the transparent type.

Covering most of a view with an overlay Android

When covering a view with an overlay I am aware that I need to use a FrameLayout, and the child views stack on top of each other. Setting a view to having a background with opacity will create the overlay effect. However, in my situation, I am required to create a hole in my overlay to display the contents of a tab item / other views beneath it. This is where I am stuck.
I am not sure how to perform the intersection on the view so that it is transparent in a specific area of the view (which I need to determine based upon the position of a specific View element (Tab, ImageView, etc).
The image above shows the result I want to achieve. With the entire view having an overlay on it, besides one of the Tabs and the Info box (which needs to move based on the view displayed through the overlay).
I believe I need an intersection of the views to achieve the result I need...this is something I am not sure about. Can someone point me in the right direction of a solution please, I do not expect to be just given a solution, its all about learning!

Controlling Z-Order of Custom Drawn View ON TOP of a SurfaceView

I was having some issues having a view on top of my surface view. I followed the instructions on this answer: https://stackoverflow.com/a/2934759/1315692
That worked great EXCEPT for a view that is custom drawn.
The custom drawn view ALWAYS remains on top. What do I need to do to be able to put a view on top of it? Thanks for any suggestions or insights.
I figured out a solution. It may not be the best solution but it is working for me.
I drew my view that I wanted on top in the draw routine of the object that was stubbornly staying on top USING THE SAME CANVAS. I added a field of type View to my SurfaceView (because that is where the view that remained on top is drawn) with a setter. Then in my draw routine I simply called passedInView.draw(canvas);
If you are at a point where you are not drawing on top of the surface view at all then start with the link from my question. That should be all you need. This is for a situation where a custom drawn view still remains.
Now this can cause some undesired behavior in regards to tapping (you can tap right through your on top view)...so you will need code to handle that but if all else fails, as it had for me, this got my view on top.

How to add view on imageView?

I have created a class that extends a view which will work as a drawing slate to draw a text. I want to add that drawing slate in image View. And I have main activity which contains a scrollable list on top and a image view below list. Now I want to add that View(Drawing slate) on image View. So how to implement this? I tried lot, but I am not getting how to do this.Do i need to use any other view instead of image View? Please help as soon as possible. Thanks in advance.
just extend ImageView and do your drawing in onDraw method, make sure you call super.onDraw()

How can an external glow/aura can be drawn to an Android button or list item

I have recently encountered a very specific issue/requirement regarding an Android Button and ListView item. The requirement is something like this:
we need a button that can display a glow/aura of a specific dimension and opacity when clicked, however this glow/aura must not be part of the button itself and needs to be displayed over the neighbouring views.
same requirement for list view items - they need to glow over their neighbouring items and the list view margin.
Any idea/suggestion would be highly appreciated.
Thanks.
A solution could be in drawing a round rectangle with stroke around the button. You can get the button position using View getTop(), getLeft(), getRight() and getBottom() methods.
The round rectangle could be a custom view that has the onDraw() method overridden. You can also have a paint attribute, in this view, if you what to add the gradient and opacity, to look more like an aura. When you first create the view it should be invisible or transparent and only on demand it should appear.
From your main activity you have to add this new view, by using the layout.addView() method and depending on your demands you can make it visible and/or change their properties.
An example can be found here: https://github.com/codesorcerers/auraview
Hope this helps!
Bogdan Popa

Categories

Resources