i have a linear layout with webview now i need to apply slide in and slide out animation, do i need to apply animation to webview or linear layout?
If applying on either of them then how to apply because setInAnimation and setOutAnimation
is not there for both.
How to do it?
Try out below animation create the two xml files in your application's res/anim
folder and paste the below code and then apply it on your webview or linearlayout.
Slide in:
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="100%"
android:toXDelta="0%"
android:duration="600" />
</set>
Slide out
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromXDelta="0%"
android:toXDelta="-100%"
android:duration="600" />
</set>
For more details check out HERE and HERE .
I hope it will help you.
Thanks.
make styles.xml and place it in res/values
<style name="MyAnimation">
<item name="android:windowEnterAnimation">@anim/slide_in</item>
<item name="android:windowExitAnimation">@anim/slide_out_</item>
<style name="SlideAnim">
<item name="android:windowAnimationStyle">@style/MyAnimation</item>
<item name="android:windowNoTitle">true</item>
</style>
make these files and place both of them in res/anim
slide_in xml
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700"/>
slide_out xml
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="700" />
And the last step is : inside your xml file where you have placed your LinearLayout or WebView apply style attribute the particular element. In the below example I have done it to LinearLayout.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="@style/SlideAnim"
android:orientation="vertical" >
....
</LinearLayout>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.