Android Animate object height

Asked

Viewed 92 times

0

I have an object in my view but it starts with visibity=GONE and would like to animate it to appear, like a slideDown and JQUERY slideup.

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:background="#2f3d4c"
    android:paddingBottom="40dp"
    android:paddingTop="20dp">

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/bt_mensagens"
        android:id="@+id/bt_mensagens"
        android:contentDescription="@string/content_bt_mensagens" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="#000000"
        android:visibility="gone"
        android:id="@+id/box_buttons_msg"
        android:orientation="vertical"></LinearLayout>

</LinearLayout>

1 answer

1

slide_up.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
    android:duration="1000"
    android:fromYDelta="100%"
    android:toYDelta="0" />
</set>

slide_down.xml:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
    android:duration="1000"
    android:fromYDelta="0"
    android:toYDelta="100%" />
</set>

Java:

final Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_down);
view.startAnimation(animation);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.