简体   繁体   中英

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.

通过添加代码来解决该问题,该代码将第二个fragment(f2)的高度设置为value,即动画完成后的高度

我不确定,但是您必须将动画对象的持续时间设置为毫秒。

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM