Alex Kucherenko
Alex Kucherenko

Reputation: 20307

View hides during animation

I have a xml-layout that consists two FrameLayouts(f1 and f2). F1 fills all screen's area, and f2 is hided under the screen by using android:layout_marginBottom="-900dp". Layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/llMainLayout" 
    android:orientation="vertical">
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">
        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:id="@+id/f1" android:background="@color/white">

            <fragment
                android:id="@+id/leftsidefragment"
                android:name="de.com.fragments.ChapterDescriptionPageFragment"
                android:layout_width="match_parent"
                android:layout_height="fill_parent"/>

        </FrameLayout>

        <FrameLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:id="@+id/flRightWindowPart" 
            android:background="@android:color/transparent"
            android:layout_gravity="bottom">

            <fragment
                android:id="@+id/f2"
                android:name="de.com.fragments.ChapterSubchaptersListFragmentWithHeader"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"/>

        </FrameLayout>
    </FrameLayout>
</LinearLayout>

Then I do the translate animation: f2 is rising up. All works fine except for one trouble - f2 is invisible during the animation. Code of method that construct the animation:

public Animation constructSlideUpAnimation(boolean inverse){
    if (inverse)
        return new TranslateAnimation(
                  Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f,
                  Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 900
              );
    else
        return new TranslateAnimation(
                  Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, 0.0f,
                  Animation.ABSOLUTE, 0.0f, Animation.ABSOLUTE, -900
              );
}

Write if you need some others chunks of code. I really appreciate any help. Thanks in advance.

Upvotes: 1

Views: 245

Answers (2)

Alex Kucherenko
Alex Kucherenko

Reputation: 20307

The problem was solved by adding the code, that set the height of second fragment(f2) to value, that will be after animation finished

Upvotes: 1

Fernando Gallego
Fernando Gallego

Reputation: 4116

I am not sure but you have to set the duration of the animation object in milliseconds.

Upvotes: 0

Related Questions