I've got a framelayout with a 2 pixel border. In the corner of the framelayout, there's a button that the user can drag to resize the layout. I'm doing the resizing by listening to onTouch and calling setScale on the framelayout.
The problem I'm having is that the border and button get skewed when I call setScale on the layout. Is there a way to achieve this resizing effect while keeping the border at 2 pixels and the button inside the layout the same size?
Related
I design a Android Layout where only a cropped part of an Image should be displayed within a frame. I do this with an ImageView within an RelativeLayout. The ImageView lies below the RelativeLayout and is larger than the RelativeLayout. The ImageView is set android:scaleType="centerCrop".
Now I need to shift the Image behind the Frame (the RelativeLayout) in order to display another part of it inside the Frame. How is this possible? A setY() on the ImageView shift the cropped Image, but the Image should first be shifted and cropped afterwards.
Have you tried paddingbottom for imageview?
paddingtop makes image to occupy less height and it gets center cropped in remaining portion
you can align you imageview with relative layout and can show rest of the view
I have total 5 image views in linear layout.first round it shows only 3 image views centre of the layout and second round first 3 image views are scale down or translate and visible the 4th image view and centre of the partent. and third round 4 views are scale down and visible the 5th image view in centre of the parent.
How to achive this in android using animations?
Animations can be performed through either XML or android code. Here you get animation using xml.
http://www.androidhive.info/2013/06/android-working-with-xml-animations/
Hope it helps !
I'm trying to do a TweenAnimation (Scale and translate) with two ImageViews (top and bottom). Each ImageView (and some other stuff) is in a RelativeLayout and the RelativeLayouts are in a LinearLayout. The images moves to the left top corner of the display. The Animation works fine, but at the end of the (Relative) Layout the animation disappears (in the mid of the display).
Is there any way to give the animation more (all) space then only the parent View? Thanks!
You can set the parent view to not clip it's children and allow them to draw outside it's bounds. In your XML, add this:
android:clipChildren="false"
i want to increase the size of ImageView/ RelativeLayout by Dragging the corner of ImageView/ RelativeLayout. But no difference in width and set it bottom. I set it by using android:layout_alignParentBottom="true" and also set image in imageview. but how to drag i don't know. Is there is any option available in Android? can any one suggest some solution for this? pls help me
you can use onTouch() for the ImageView.
Once it is touched show a small image at the edge of the imageview. And on touching that image and moving(onTouch() gives the pixel positions until you touch it) you will be getting the pixel positions. Based on that you can set the height and width of the imageview.
I have a RelativeLayout filling the screen and a couple of ImageView positioned on it using LayoutParams margins. These ImageView are animated in different ways, and in one case I want an image to "fly in" to the screen from the right.
Unfortunately, if I set leftMargin for that ImageView greater than the width of the screen, it does not appear (or appears cropped if it partially visible at the start of animation).
I tried setting width and height of RelativeLayout to be bigger than screen size - it works, but only partially: if the image is positioned completely off-screen, it does not work, and if the image is partially visible, it is not cropped, but that works only for right and bottom sides.
So, my question is this: how to position several ImageViews on and off the screen so that I can animate them using Animation?
In the end, I used a trick: I combined AnimationDrawable and view animation. I did the following (assuming that the animation has to run T milliseconds):
Position that ImageView on-screen.
Set as its background an AnimationDrawable with following frames:
empty Drawable: 1ms,
normal Drawable: Tms.
Change view's animation to this:
jump to off-screen position (translation with duration=1ms),
do normal animation.
This is probably a good place to start looking for those who would use Fixpoint's solution.
Android — How to position View off-screen?