У меня есть xml-layout, который состоит из двух FrameLayouts (f1 и f2). F1 заполняет всю область экрана, а f2 скрывается под экраном с помощью андроида: 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
);
}
Напишите, если вам нужны другие куски кода. Я очень ценю любую помощь. Заранее спасибо.
Проблема была решена путем добавления кода, который устанавливает высоту второго фрагмента (f2) для значения, который будет после завершения анимации
Я не уверен, но вы должны установить продолжительность анимационного объекта в миллисекундах.