【问题标题】:Translate animation is behind other components翻译动画落后于其他组件
【发布时间】:2016-07-15 14:08:39
【问题描述】:

我的布局由如下所示的图像部分组成。我只想使用从底部开始的翻译动画设置所有图像资源。这样做时,动画在其他图像布局之后开始。我只是在寻找解决方案,但没有找到解决方案。

android:clipChildren="false";   
yourLayout.bringToFront();   
setZAdjustment(Animation.ZORDER_TOP);

以上所有解决方案都不适合我。有人可以帮助我吗?

我创建图像按钮的 xml 代码是

 <TableRow
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1">

    <LinearLayout
        android:layout_width="0dip"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:adjustViewBounds="true"
        android:background="@drawable/bck_game_image"
        android:layout_margin="1dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_margin="4dp"
            android:background="@drawable/bos">

            <ImageButton
                android:id="@+id/buton0"
                android:layout_width="0dip"
                android:layout_height="fill_parent"
                android:layout_weight="1"
                android:adjustViewBounds="true"></ImageButton>
        </LinearLayout>

    </LinearLayout>
.....
</TableRow>

【问题讨论】:

  • 请发布您的xml代码
  • 更具体。我不明白你的问题。您要为哪些布局设置动画?您可以使用 Java 代码轻松完成。
  • 我正在为上面的 ImageButton 设置动画。

标签: android android-layout animation translate-animation


【解决方案1】:

不要使用 yourLayout.bringToFront(),而是使用以下代码行:-

linearLayout.bringChildToFront(imageView);
linearLayout.requestLayout();
linearLayout.invalidate();

【讨论】:

  • 它可以工作,但是图像按钮的索引在上面的代码行之后发生了变化。例如我为左上角的图像按钮设置了动画,但是它会影响右上角的图像按钮。跨度>
  • 索引,你的意思是ImageButton的ID?还是别的什么?
  • 当我使用你指定的代码时,动画正在影响另一个图像按钮,而不是我的目标。我认为图像按钮的位置正在改变。
  • 请发布您的动画代码。更新您的问题并将其添加到那里。
猜你喜欢
  • 1970-01-01
  • 2015-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-05-22
  • 1970-01-01
  • 2012-04-13
相关资源
最近更新 更多