Android animated transition - android

How to make circular animated transition from top left to right bottom not as traditional way, I tried
<translate
android:duration ="1200"
android:fromYDelta="-1000"
android:toYDelta="0"
/>

You could use Android transition API. If you're supporting Lollipop+ (ArcMotion was added in Lollipop while transition API is available from KitKat) you might use native transitions, otherwise you might want to use Transitions-Everywhere library. I think this does what you want to do: https://github.com/andkulikov/Transitions-Everywhere/blob/master/sample/src/main/java/com/andkulikov/transitionseverywhere/PathMotionSample.java

Related

Android new fragment appears below old one during fragment animation

I'm using animation between my fragment :
slide in from left :
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="x"
android:valueFrom="2000"
android:valueTo="0"
android:valueType="floatType"
android:fillAfter="true"/>
</set>
slide in from right :
<?xml version="1.0" encoding="utf-8"?>
<set>
<objectAnimator
xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="600"
android:propertyName="x"
android:valueFrom="0"
android:valueTo="-400"
android:valueType="floatType"/>
</set>
This animation move the previous fragment to left and the new one come from the right. I'm using it with a fragment transaction.
transaction.setCustomAnimations(R.animator.slide_in_from_left,R.animator.slide_in_from_right);
I got a trouble when the new fragment come he slide below the older one, for fix it I put an elevation on my new fragment but I would like a solution for API below 21.
Is it possible to force the new fragment to be above the older fragment
If I understand correctly, you are using the android:elevation attribute on your new fragment (if not, feel free to write about your method) - altough it only works on Lollipop and above, as you also mentioned. However, based on the linked topic below there are several ways to achieve elevation effect on pre-Lollipop devices.
"android:elevation=" doesn't work on devices pre-Lollipop with compile API21
EDIT AFTER FIRST COMMENT: Okay, sorry for misunderstanding your question... :)
As I searched a little bit in the topic, there were some interesting examples with a new fragment overlapping an older one, they are listed below. The first 2 examples need some special layout design and extensions of existing view classes, but maybe one of them is what you're looking for.
In my opinion the prettiest solution would be based on this example: http://swarmnyc.com/whiteboard/android-fragment-animations (the layout does not contain a FrameLayout to replace fragments, it contains the fragment(s) by the <fragment> tag; in the code you can use simple transition animations; you can find the source code at the end of the topic)
Here's another one: http://trickyandroid.com/fragments-translate-animation/ (you can see an extension of the native RelativeLayout view class with built-in functions to achieve animation; source code also provided at the end of the topic)
Moreover (without source code) I could suggest you 2 more ways:
The animation you search for could be perfectly achieved by using
activities for displaying the UI and the
overridePendingTransition() method inside the activity after startActivity(intent). However if
you really would like to use fragments, maybe you will skip this.
The last (and I think the simpliest) solution could be to overlap the old fragment by adding a new
fragment instead of replacing it. However I think this is the worst
solution because of possible memory usage problems (older
fragments won't be removed, just simply faded by newer fragments).
I hope I could help... :)
If fragment appears below another one is because the fragment container is not the good container type
You need to put fragment inside FrameLayout or RelativeLayout, if you want to test you can paste your fragment layout code at the bottom of the fragment container for have a preview

How I can implement a button on Android like this (3D-ish)?

I want to implement a button like the one in the "Big Web Quiz App" (Link to Play Store).
For me, it doesn't seems to use some sort of OpenGL, i can't found any references on the dissasembled code. Maybe is an image?
Thanks in advance
UPDATE: I've uploaded a video, to state clearly that there is a transition, it's not a pressed-unpressed button. LINK
You can achieve this by using Frame Animations, its like a short video build from few images.
animation-list is one option to go, read more about it here:
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="true">
<item
android:duration="500"
android:drawable="#drawable/ic_heart_0"/>
<item
android:duration="500"
android:drawable="#drawable/ic_heart_25"/>
<item
android:duration="500"
android:drawable="#drawable/ic_heart_50"/>
<item
android:duration="500"
android:drawable="#drawable/ic_heart_75"/>
<item
android:duration="500"
android:drawable="#drawable/ic_heart_100"/>
</animation-list>
News since 2015 to Aug 2016 lol
Today there are more options to solve this problem, you can use AnimatedVectorDrawable or ObjectAnimator or use android-pathview library that was developed on top of AnimatedVectorDrawable, it makes the life easier. But in any way you will have to put some work to achieve your desired effect.
Off the cuff, this would seem to require a custom widget.
The widget itself would consume the entire space, from the upper-left corner of the foreground through the bottom-right corner of the 3D background. The custom onDraw() of the widget would render the foreground, perhaps in the form of a TextView with a compound drawable on the left. onDraw() would also render the shaded parallelograms that form the 3D effect, to consume the rest of the space between the foreground and the lower-right corner of the widget.
On a click event, you would use the animator framework to change the size of the widget, anchoring it on its bottom-right corner. The animation would change the size to the smallest position, then reverse it back to its original size (assuming that this button is to behave like a Button, instead of some sort of CompoundButton). The onDraw() logic should be able to handle this, rendering the foreground in the correct location and reducing the size of the parallelograms accordingly.
This is all an educated guess, as I have never tried anything like this. It will also get complicated if you want to support RTL by reversing the 3D effect (foreground moves down to the left, instead of down to the right).

Android support fragment animation problems

I have created an app that uses fragment animations for loading and unloading fragments.
I have saved the animation xml files in res/anim folder and passing it in setCustomAnimation method.
The animations worl flawlessly on my Kitkat phone but on my another FroYo phone, no animation takes place and the things just appear normally.
The weird fact is that the view animations are working on both devices.
I have tried setting the hardwareaccelerated attribute to true but that dint solve it either
Can you please help?
There's a bug on Android pre-ICS where durations set on an AnimationSet in XML are not respected. To fix this, apply the animation duration to all child animations in the AnimationSet instead.

fragment animation using objectanimator on pre-honey

I want to use property animation on my app instead of using tween animation on fragment
Right now, I use NineOldAndroids for normal property animation in my app and it works perfectly.
However, I cannot find the way to integrate this NineOldAndroid with support fragment.
Are there any way to animate fragment with property animation on pre-3.0?
Thanks.
I found this library.
It integrates support library from Google with NineOldAndroid.

Dropdown menu in android

I wanna make a dropdown-menu like the one in the attached picture in android I searched a lot but I Couldn't find anything?
Could you tell me how to start?
If you are trying to do something where you see a list of items as you type in text into a TextView, you may be looking for an AutoCompleteTextView. An implementation example can be found here.
If you are trying for the more usual drop down menu, you may want to use a Spinner widget. An example of its implementation can be found here.
Let me know if you need any more help.
Android does not generally use a "dropdown-menu" like the one you have in your screenshot. I encourage you to learn the Android UI framework and stick to it.
In Honeycomb (the tablet UI), there is the "nav mode" of the action bar that will look a bit similar, though it is not designed to be a menu.
Your best bet is going to be to make a view with the menu you want.
Then make an animation that will grow the X and Y scale over some amount of time.
Ex:
android:fromXScale="0.1"
android:toXScale="1.0"
android:fromYScale="0.1"
android:toYScale="1.0"
android:pivotX="50%"
android:pivotY="0%"
android:duration="#android:integer/config_shortAnimTime"
Then all you have to do is apply the application to your view in the appropriate onclicklistener

Categories

Resources