相关疑难解决方法(0)

Android - 如何在屏幕外定位View?

我正在尝试在我的应用程序中为一个简单的ImageView设置动画,我希望它从屏幕底部滑入并进入静止位置,其中视图的顶部50px离开屏幕顶部(例如最终位置)在X中,ImageView应该是-50px.我曾尝试使用AbsoluteLayout来做到这一点,但这实际上切断了ImageView的前50px,使得前50px永远不会被渲染.我需要让ImageView的前50px可见/渲染,同时它是动画,然后让它稍微离开屏幕.我希望我已经解释得那么好了.

这是我目前正在使用的布局和幻灯片动画(这当前不会渲染ImageView的前50px):

布局:

<?xml version="1.0" encoding="utf-8"?>
   <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_height="fill_parent" 
      android:layout_width="fill_parent" 
      android:id="@+id/QuickPlayClipLayout">
      <ImageView android:id="@+id/Clip"
         android:background="@drawable/clip" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_y="-50dp">
      </ImageView>
   </AbsoluteLayout>
Run Code Online (Sandbox Code Playgroud)

动画:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
   <translate android:fromYDelta="100%p" 
       android:toYDelta="0"
       android:duration="1000"/>
   <alpha android:fromAlpha="0.0" 
       android:toAlpha="1.0"
       android:duration="1000" />
</set>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

layout animation android imageview

61
推荐指数
5
解决办法
8万
查看次数

标签 统计

android ×1

animation ×1

imageview ×1

layout ×1