- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有一个名为 myimage 的 ImageView。
我正在从一侧的屏幕外到另一侧的屏幕外进行 TranslateAnimation。
Animation animation = new TranslateAnimation(0, 0, -1500, 1500);
animation.setDuration(1000);
animation.setFillAfter(false);
myimage.startAnimation(animation);
有什么方法可以让我将它从屏幕的一侧移到屏幕的另一侧,而不管屏幕尺寸如何?
最佳答案
我现在明白了。
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
final float screen_width_half = metrics.widthPixels/2;
final float distance = screen_width_half + 50;
//determine half screen width and add 50 to it to take it just a little outside the screen
Animation animation =
new TranslateAnimation(0, 0, -distance, distance);
animation.setDuration(1000);
animation.setFillAfter(false);
myimage.startAnimation(animation);
关于android - 从一侧的屏幕外到另一侧的屏幕外进行 Translate TranslateAnimation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28252379/
我想为 fragment 过渡制作自己的动画。我希望它从底部快速进入,然后在到达其位置时减速。我过去做过类似的事情,但我没有代码了,我也无法重现它:/我记得它与插值器有关。 这是我当前的动画集
我的设备分辨率是1080*1920(纵向),我的webview尺寸是1080*960 我在 WebView 上使用 TranslateAnimation 将其翻译从 y=0 到 y=960。 Tran
我有一个关于 TranslateAnimation 的问题。是否可以强制动画发生在其他观点之上?我试图在 LinearLayout 中将第一个子元素平移到其他元素之上。 我以为 setZAdjustm
我的 TranslateAnimation 有效,但在动画结束时,它会跳回原来的位置。 LinearLayout rl = (LinearLayout) findViewById(R.
我正在尝试创建移动图像的动画。 让我们看看以下内容(例如屏幕上的图像位置): 01 02 03 04 如果我从01移动到02,03移动到04,01> 到 03,02 到 04,TranslateAni
我正在尝试在 ImageView 上启动 Shiny 效果动画。问题是动画没有显示在屏幕上。 只有当我在按钮监听器中启动它时它才有效。 这是我的 shine_effect.xml 文件: 这
我尝试在 xml 文件中定义动画,但它没有提供足够的灵 active 。关于如何使它在代码中工作的任何想法。 我的图像消失,然后在动画开始时重新出现。本质上,当我抬起手指时,我需要图像以慢速滑动的方式
我正在开发使用了 TranslateAnimation 的应用程序,但我想将 TranslateAnimation 反转到起始位置。 protected void onCreate(Bundl
如果您在按钮上执行 TranslateAnimation,则只有绘图会移动,而实际按钮不会移动,因此您必须使用动画监听器自己移动按钮。 现在您知道我已经知道和做过的事情了,而且这行得通。 问题在于用户
有没有办法让动画暂停半秒? 我正在尝试使用 TranslateAnimation API 制作无限动画。因此,我将 RepeatCount 用作 Infinite。我还注意到有一个 setStartO
我想为从屏幕中央开始的 ImageView 设置动画,并将其向上移动到屏幕顶部下方 10 像素处。如何在代码中实现这一点? 我目前正在做的是,我正在获取另一个图像上的屏幕坐标,并将这个动画图像稍微放在
我想模拟一个上滑动画。我的想法是在按下按钮时使用 id searchForm 上滑和下滑表格布局,这样我就可以将额外的空间用于列表。我设法向上滑动 searchForm 和按钮,列表似乎是可见的,但在
我使用了一些我为滑动面板找到的代码,基本上它可以工作,但有一个小问题。 动画在面板第一次打开时不起作用。 这是动画的代码: TranslateAnimation anim = null;
我想做的是在 PIXELS 中将多个 View 动画化到特定位置!我为此使用了 TranslateAnimation。我想从显示器的左上角开始制作动画,我相信 x: 0 和 y:0 到可变位置。
我想使用 TranslateAnimation 移动一些线性布局。我有两个问题。我的基础 SDK 是 Android 2.2。 即使动画结束,线性布局中的可触摸区域也没有移动。 动画结束后屏幕闪烁了几
我正在尝试在单击时移动按钮(带动画)。我希望它在第一次单击时将 100 像素移动到底部,在第二次单击时将 100 像素向上移动,在第三次单击时将 100 像素移动到底部,依此类推。我有简单的布局文件(
我正在创建类似于 SlideDrawer 的东西,但具有大多数自定义功能,基本上可以正常工作,但动画最后会闪烁。 为了进一步解释,我得到了一个 TranslateAnimation,然后在这个动画之后
我现在很绝望,我真的需要一些帮助。我想要一个图像从屏幕右侧移入其中。 最初,图像存在于屏幕区域之外。但是,基于一个事件,我希望它滑入。 有谁知道如何做到这一点?我在网上的教程(http://devel
如何使用平移动画获取移动 View 的位置。 TranslateAnimation animation = new TranslateAnimation(0.0f, 300.0f,
我正在尝试制作这样的动画: 上下文: 我有两个 EditText,我需要当你点击一个时,另一个从第一个后面出现。在这里你有一些图片来获得我想要的图像。 显然,要做到这一点,我需要一个 Translat
我是一名优秀的程序员,十分优秀!