I have a LinearLayout [Horizontal Orientation] in which I have several ImageView objects side by side. I need to be able to drag the ImageView objects side to side.
I can drag them, but I need to be able to draw them ontop of each other as I am dragging.
So, if I have
(imageA)(imageB) side by side, and I am dragging imageA in the direction of imageB, I need imageA to draw on top of imageB and viceversa.
So far, I can get the dragging done no problem [by extending ImageView, capturing onTouchEvent, overwriting the onDraw method, and translating the canvas] however, as soon as the ImageView is moved, it is clipped because of its bounds. I try setting new bounds for the drawable of the ImageView but that doesn't work either.
How do I draw one ImageView on top of another ImageView [without using FrameLayout] ?
Thanks,
Related
I have a relative layour and a imageview inside of it. I want to move the imageview to the touch position.
I have tried these methods for X and Y
view.setX()
view.setTranslationX()
view.setTop()
view.animate().x()
none of them is working, nothing happens.
The code runs inside PagerAdapter. I have an imageview that takes all screen and i set onTouchListener for it, get touch coordinates and set them to another imageview, that is a red circle, to move it to the touch location, but it is not moving at all.
I have an ImageView set to scaleType="centerCrop" , I am trying to create an animation which pans this ImageView to its left and right edges, which are outside of the bounds of the view.
How would I do this?
Normally when animating I have the full view on screen already, but in this case the ImageView itself is rendered but its source is scaled outside the bounds of its view. So if I was just animating the VIEW itself I won't be accessing the source.
This may have something more to do with animating on a canvas within an imageview, instead of moving the X, Y position of the imageview itself. Insight appreciated
Regarding the "too broad" allegation to close this question, yeah, it isn't.
I was able to do this with the KenBurnsView library object
https://github.com/flavioarfaria/KenBurnsView
I modified my version to use my custom imageview objects which extend NetworkImageView from Volley
I have a transparent layout in android, and behind the layout there is an image. how to make the linear blur ? I found examples to make the image itself blur but I don't want to make whole image blue, just only the part that is behind the linear layout.
Set a semitransparent Blur image to the linear layout or simplest set a color to linear layout and set it to semitransparent by defining alpha
edited solution
do this...
1.) create a blur copy of the image u have on background.
2.) clip the image by using
Bitmap croppedBmp = Bitmap.createBitmap(originalBmp, startX, startY, widthLayout , heightOfLayout);
3.) set this image in the Linear Layout using an image-view with height and width attribute as fill-parent.
I have pretty complex solution, so there won't be any code. So, here is idea, step by step:
Let's assume that your layout have just single custom LinearLayout. No ImageView as a background.
What we going to do, is draw background drawable of LinearLayout by our own, so it will first draw full image and then draw blurred square from the same image on top. Content of LinearLayout might be moved to desired position using paddings.
So, create something like MyLinearLayout and put it to your layout resource. Provide required constructors.
Override onAttachedToWindow() and onDetachedFromWindow() methods. Inside them we should load our background Bitmap and recycle it accordingly. Let's name it mBackground
Override draw() method. Inside it we're going to first draw our mBackground.
Then, you can use Canvas#clipRect() method to crop drawing area of Canvas to some specified rectangle. In your case, this rectangle should be the area below your content. You can figure it out using View#getPadding*() methods. Don't forget to call canvas#save() before clipping drawing area.
Now you can draw your bitmap once again with blur (I don't know which method exactly you're using, so let's assume that you know how to do it... but you still can share it with us :) ). Cool thing is that you can just draw the same Bitmap once again in full scale - since we had called clipRect before, it will be drawn only within this area. Don't forget to call canvas#restore() after drawing background.
Call super.draw() to draw rest of the stuff, that your LinearLayout contains.
*Can anybody tell me how to do this *
I am new in android.I wanted to create animations for below :
I have two views : 1.Image drawn by canvas (assume DrawView) & 2. TextView
I added rotation to DrawView from -90 to 90 (works like its wiping screen from bottom left corner to bottom right corner in circular motion)
Now I want to show TextView just like DrawView image is uncovering Textview.
I think Drawview should act like foreground view and textView like background .
I am adding image for better explaination!
Image Link :
https://docs.google.com/file/d/0B8DGjJBt0XQ_TVBtS0lidUFhZzA/edit?usp=sharing
Thanks in advance
I used two views in frame layout.
made Image drawn by canvas (assume DrawView) as front view .
using DrawView.bringToFront();
Worked !
I have relative layout as a main View and it has few Image views which are place w.r.t to margin top and margin left. Now I want to check the imageViews opacity or transparent region at the pixel where touch is happened. Say I touched some where 533,240 .. I want to check whether that position is transparent or transculent or opaque.. Since imageview will always be square and i guess there will be part of image will be transparent but it should not be included in onTouch event thats why I aim for this that if i get the position of my touch w.r.t to local co-ordinate of the Imageview then I can give that pixel to the drawable.getTransparentRegion.container(int x , int y )
Explaining further.. .what I am trying to do is I am getting View on click or on touch.. From that view I am getting imageview ....and from that imageview I am trying to get Drawable of that imageview ..I have reached till here ... Now I want to get the touch event position w.r.t to the imageview so I can check it in drawable.getTransparentRegion ? ... I hope you understood
At the end I want to differentiate between the transparent part of the imageView i.e.(not needed part of the Imageview ) and the Transculent part that will be there of the drawable in the imageView...
get coordinates of imageview on window by
public void getLocationInWindow (int[] location),
pass integer array of two size to this method. Invoke this method after layout has been drawn, use location array to get imageview's left and top co-ordinates, add transparent co-ordinates to it, and you will get co-ordinates which can be compared to touchevent co-ordinates.