Use android:animateLayoutChanges on the LinearLayout that shall hold the data. This will trigger an animation when adding new content. It starts by moving the old data down making room for more content. Then follows a second step where the new data will fade into the free space.
Example code
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/baseLL"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<!-- button used to add data -->
<Button
android:layout_width="192dip"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Add Content"
android:onClick="onAddContentClick" />
<!-- button used to remove data -->
<Button
android:layout_width="192dip"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Remove Content"
android:onClick="onRemoveContentClick" />
<!-- data will be added to this LinearLayout at run time -->
<LinearLayout
android:id="@+id/dataLL"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:animateLayoutChanges="true"
>
</LinearLayout>
</LinearLayout>
basicanimation.java
package com.test.animation.basic;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
public class BasicAnimationActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onAddContentClick(View v) {
LinearLayout dataLL = (LinearLayout) findViewById(R.id.dataLL);
int dataCount = dataLL.getChildCount();
TextView newDataTV = generateData(dataCount);
dataLL.addView(newDataTV, 0);
}
public void onRemoveContentClick(View v) {
LinearLayout dataLL = (LinearLayout) findViewById(R.id.dataLL);
if (dataLL.getChildCount() > 0) {
dataLL.removeViewAt(0);
}
}
private TextView generateData(int dataCount) {
TextView TV = new TextView(this);
TV.setText("Data " + dataCount);
TV.setLayoutParams(new LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
return TV;
}
}