2012-05-23 60 views
1

我有一个由两个FrameLayouts(f1和f2)组成的xml布局。 F1填充所有屏幕的区域,并通过使用android:layout_marginBottom =“ - 900dp”将f2隐藏在屏幕下方。 布局:在动画中查看隐藏

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

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

回答

1

问题是由添加代码,即设置第二个片段(F2)价值的高度,这将是动画完成

0

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

+0

后,你的意思是动画的时间解决了吗?它以毫秒为单位设置500 –