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"
Related
I'm trying to create this kind of layout in android.
I'm using constraint layout. I want to divide the screen with height y to two halves with y/2 height each.
Each one of them will have a textview as title which takes the whole width and has constant height.
And a circular custom view which I would like to expand or shrink so it fills the whole half so the padding marked as 'auto' will all be the same but dynamic.
And p will be a minimum padding that the view can't be over them.
The aspect ratio should of those circles should not be changed.
Is that even possible doing it in the xml design editor? or do I have to do it programmatically.
Next step will be to arrange those halves to be side by side if it's a landscape view.
OK, I did it, Basically you drag the 4 edges of a each view to center it in the outside element. And set the margins to .
So I dragged title2 to all directions of the screen and it got centered. Then I dragged each of the circular views edges the same way so the upper view I dragged to title1 and the bottom to title2. The bottom view I dragged its top to title 2 and the bottom to the bottom of the screen.
Auto resizing is done by setting layout_width to 0 and layout_height 0.
In my layout file I have a ConstraintLayout as the parent and 2 child views.
Player View (displayed with ratio of 16:9)
Controls View
I need to layout the player controls on top of the player view (cover it) and add 10dp of height so it goes even a little higher than the player view.
Is there a way to achieve this with ConstraintLayout without adding more ViewGroups to the picture?
Here is one way to do it:
Place a Space view on top of the player. Make the height of the Space view 10dp.
Constrain the control's top to the top of the Space view and its bottom to the bottom of the player.
The Space view will not show but will help to provide the positioning you want.
The pattern of the layout is below:
---LinearLayout vertical
---LinearLayout -> contains a LinearLayout that shapes like rectangle(setVisibility-> Gone)
---RecyclerView -> below the above layout of rectangle
Originally, I set a slide-down animation of RecyclerView from the top of the window to a position where it gives enough space for the rectangle to show and when the animation ends the LinearLayout of rectangle is shown by invoking the method setVisibility(Visible)
Problem: when I set the rectangle visible, it is visible as expected but recycler view is dropped down the space as much as the rectangle's height, leaving blank space between the rectangle and the RecyclerView. I wonder what might cause this and how to fix this? Thanks!
I think you may not change the position of the RecyclerView and only set the visibility of the LinearLayout to visible. Changing the visibility will redraw the whole layout and the layout that was Gone will take its needed height, so the space between the top of the recycler view and the bottom of the layout will be (animation height + layout height) and that is why there is an empty space
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?
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?