animateLayoutChanges为true导致布局在android

时间:2016-01-05 04:11:00

标签: android android-animation

我将元素从一个Horizo​​ntalScrollView拖到另一个Horizo​​ntalScrollView。

当我删除时,我从底部Horizo​​ntalScrollView中删除视图并将其添加到顶部Horizo​​ntalScrollView。我通过设置xml android:animateLayoutChanges="true"

来设置更改动画

这些变化正在变化,这不是问题。问题在于,无论何时触发这些动画,布局都会上下移动。当我拖动一个项目时,它会向上移动而在另一个拖动时它会向下移动。并且它会重复所有后续的拖延。

以下是显示问题的视频:https://sendvid.com/uqnnwc4v

我的XMl是这样的:

<RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="320dp">
        <include layout="@layout/content_package_description_horizontal_view"/>
       ........
    </RelativeLayout>
..........
..........
..........
<HorizontalScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none"
        android:scrollbarSize="0dp">
        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:animateLayoutChanges="false">
            <!-- Package list -->
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
            <include layout="@layout/service_single_hero"/>
        </LinearLayout>
    </HorizontalScrollView>

我正在添加到像这个

这样的上部Horizo​​ntalScrollView
// Adding to Horizontal view
    FrameLayout thisHorizontalBigItem = (FrameLayout) getLayoutInflater().inflate(
            R.layout.package_description_horizontal_item_big, null, false);
    TextView thisHorizontalBigTextView = (TextView) thisHorizontalBigItem.findViewById(
            R.id.selected_service_item_big_text_view);
    thisHorizontalBigTextView.setText("ID : " + itemID);

    horizontalItemsContainer.addView(thisHorizontalBigItem, 0);

从底部的Horizo​​ntalScrollView中删除:

// Remove the selected service from bottom list
    try {
        for (int i = 0; i < servicesItemsContainer.getChildCount(); i++) {
            View thisServiceItem = servicesItemsContainer.getChildAt(i);
            JSONObject thisItemJSON = new JSONObject(thisServiceItem.getTag().toString());
            if (thisItemJSON.getInt("id") == itemID) {
                servicesItemsContainer.removeView(thisServiceItem);
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }

请告诉我这里有什么问题?

0 个答案:

没有答案