Kevin van Mierlo
Kevin van Mierlo

Reputation: 9814

LayoutTransition with ScrollView

If I do LayoutTransition inside my ScrollView (animation is done on a LinearLayout), it expands very nice. However if I delete something everything gets pushed up while the animation is busy, which looks ugly. It is somewhat the same as this question: LayoutTransition: 2 containers

Here is my xml:

<ScrollView 
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fillViewport="true">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <LinearLayout
            android:animateLayoutChanges="true"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@drawable/card"
            android:orientation="vertical"
            android:paddingBottom="@dimen/activity_vertical_margin"
            android:paddingLeft="@dimen/activity_horizontal_margin"
            android:paddingRight="@dimen/activity_horizontal_margin"
            android:paddingTop="@dimen/activity_vertical_margin">

            <View
                android:layout_width="match_parent"
                android:layout_height="5dp"
                android:layout_gravity="left"
                android:layout_marginRight="1dp"
                android:background="#00000000"/>

            <Button
                style="?android:attr/spinnerStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:layout_marginTop="@dimen/activity_vertical_margin"
                android:paddingLeft="@dimen/activity_horizontal_margin"/>

            <Button
                style="?android:attr/spinnerStyle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:paddingLeft="@dimen/activity_horizontal_margin"/>

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/activity_vertical_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:ems="10"
                android:gravity="start"
                android:hint="@string/addassignment_description_hint"
                android:inputType="textMultiLine|textCapSentences"
                android:minLines="3"/>

            <Button
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="@dimen/activity_vertical_margin"
                android:layout_marginLeft="@dimen/activity_horizontal_margin"
                android:layout_marginRight="@dimen/activity_horizontal_margin"
                android:textColor="@android:color/white"/>
        </LinearLayout>

        <FrameLayout
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1">

            <com.google.android.gms.ads.AdView
                android:id="@+id/adView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:background="@android:color/black"
                ads:adSize="SMART_BANNER"
                ads:adUnitId="@string/ad_unit_id"/>
        </FrameLayout>
    </LinearLayout>
</ScrollView>

Does anybody have a clue how to make the ScrollView animate nicely with the LinearLayout?

Upvotes: 2

Views: 569

Answers (0)

Related Questions