【问题标题】:ViewFlipper stacks child views on 'outAnimation'ViewFlipper 在“outAnimation”上堆叠子视图
【发布时间】:2011-10-21 20:17:55
【问题描述】:

我有一个 viewFlipper 可以在许多 textView 之间翻转。 出于某种原因,视图堆叠在 outAnimation 上。而不是只有一个执行“动画中”和一个执行“动画外”我有一个执行“动画中”和所有以前的视图都执行“动画外”,有人可以帮助我实现视图不会相互堆叠的状态动画?

这里是脚蹼 xml:

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content"
        android:id="@+id/viewFlipper1"      
        android:background="#60000000"
        android:inAnimation="@anim/flipper_transition_in"
        android:outAnimation="@anim/flipper_transition_out"
        android:autoStart="true"
        android:flipInterval="5000">

        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="אין דבר העומד בפני הרצון"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView> 

        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="קשה – זאת אומרת אפשר"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView>
        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="מי שלא מעז – לא מצליח"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView>
        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="אל תצפה לזה - תעבוד בשביל זה"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView>
        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="אל תוותר על מה שאתה רוצה"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView>
        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="דברים גדולים דורשים זמן"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView>     
        <TextView  android:layout_width="fill_parent"
            android:layout_height="wrap_content" 
            android:textSize="20sp"
            android:text="כשתגיע לשם תצחק על כולם"
            android:textStyle="bold"
            android:gravity="center"
            android:textColor="#00ff00"
            android:singleLine="true"
            >
            </TextView>

这里是动画 xmls:

在动画中:

 <set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator"
>
 <translate android:fromXDelta="-100%p" android:toXDelta="0" android:duration="5000"/> 

出动画:

 <set xmlns:android="http://schemas.android.com/apk/res/android"
    android:interpolator="@android:anim/linear_interpolator"
    >
 <translate android:fromXDelta="0" android:toXDelta="100%p" android:duration="5000"/>

注意我的动画从左到右翻译文本,这是我需要的,不是错误。 任何帮助将不胜感激!!!提前致谢!

【问题讨论】:

  • 如果使用设置动画,您需要有一个关闭标签。但是因为你只做一个动画,所以不需要 set 标签。
  • 有一个 标签,如果这就是你的意思......否则 Eclipse 不会让我编译它。不管怎样,你知道为什么我的观点会堆积在 outAnimation 中吗?我试过 clearDisappearingChildren() 但它没有帮助...... :(

标签: android android-layout viewflipper android-animation android-xml


【解决方案1】:

嘿,您的代码似乎有效。我确实在 viewflipper 标签中做了一个小改动。

<ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" android:layout_height="wrap_content"
    android:id="@+id/viewFlipper1" android:background="#60000000"
    android:inAnimation="@android:anim/slide_in_left" 
    android:outAnimation="@android:anim/slide_out_right"
    android:autoStart="true" android:flipInterval="5000">

我没有使用您编写的动画代码,而是使用了android sdk中的动画。 顺便说一句,您的代码没有结束 viewflipper 标记。而不是使用 采用 。你没有封闭任何东西,所以结束标签并不是真正必要的。

【讨论】:

  • 谢谢,现在就足够了,尽管我无法判断视图是否与此动画叠加(由于速度原因,这不是必需的)。如果您遇到过一种方法来制作不叠加视图的平移、匀速动画,请在此处发布:)
  • 顺便问一下,我可以在 sdk 的哪里看到所有提供的动画?
  • 在 Eclipse 中,如果你点击了 android.R。您将获得 sdk 中所有资源的列表。顺便说一句,请点赞。然后我不确定您的要求是什么,因为上述方法是您在视图之间循环的方式。但是,如果您正在寻找一个连续的滑块,这可能会有所帮助github.com/blessenm/SlideshowDemo
  • 谢谢,这正是我需要的效果。抱歉,不能投票,说我需要至少 15 的声誉:P
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-26
  • 2016-04-16
相关资源
最近更新 更多