TOP
TOP

Reputation: 2624

How to animate whole LinearLayout and its inside views Android?

I have a LinearLayout, which contains some ImageButtons. I want to fadeout the LinearLayout and its children. I tried to use AlphaAnimation. If I start animation with ImageButton inside LinearLayout, everything works fine. But when I start animation with LinearLayout instead of ImageButtons, nothing happens. Can anybody help me?

Upvotes: 0

Views: 4672

Answers (2)

Muhammad Hassaan
Muhammad Hassaan

Reputation: 1017

Simply Pass android:animateLayoutChanges=true to Linear Layout that hold all layouts, you will get desired results

Upvotes: 1

Manish
Manish

Reputation: 1003

You can try following animation xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
 android:interpolator="@android:anim/linear_interpolator">
  <alpha
      android:fromAlpha="0.0"
      android:toAlpha="1.0"
      android:duration="5000"/>
</set>

and then can try following code snippet

LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);
Animation anim = AnimationUtils.loadAnimation(this, R.anim.fade_in);
layout.startAnimation(anim);

Its worked fine for me.

Upvotes: 2

Related Questions