我有一个活动,其布局仅包含一个 VideoView。这是 XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
>
</VideoView>
我试图在停止播放后将此动画应用到 VideoView:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate android:fromYDelta="0%" android:toYDelta="-100%" android:duration="500"/>
<scale
android:fromXScale="1.0"
android:toXScale="0"
android:fromYScale="1.0"
android:toYScale="0"
android:duration="500"
android:pivotX="50%"
android:pivotY="0%"
/>
</set>
如图所示,效果非常好。但是,如果我在布局中从 LinearLayout 切换到relativelayout,则动画将不再起作用,并且视频只会冻结在停止之前显示的最后一帧。
为什么我的活动中的根布局类型会导致动画无法正常运行?
编辑:如果我添加这个 TextView 会增加奇怪的感觉
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" ">
</TextView>
对于VideoView 下面的RelativeLayout,动画就会起作用。但是,如果我从 android:text 元素中取出空间,那么它又回到不工作状态。 o.O
编辑:我已向 Beowulf Bjornson 授予赏金,以表彰其使用更新的动画框架的好技巧。
但我仍然非常感兴趣,如果有人弄清楚在这种情况下旧式动画发生了什么,我会非常乐意为此提出更多的观点。