1

我有一个包含两个 FrameLayouts(f1 和 f2)的 xml 布局。F1 填满屏幕的所有区域, f2 通过使用 android:layout_marginBottom="-900dp" 隐藏在屏幕下方。布局:

<?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>

然后我做平移动画:f2 上升。一切正常,除了一个问题 - f2 在动画期间是不可见的。构造动画的方法代码:

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
              );
}

如果您需要其他一些代码块,请编写。我真的很感激任何帮助。提前致谢。

4

2 回答 2

1

通过添加将第二个片段(f2)的高度设置为值的代码解决了这个问题,这将在动画完成后

于 2012-05-25T08:54:11.133 回答
0

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

于 2012-05-23T15:30:39.883 回答