简体   繁体   English

使用动画将视图移动到屏幕顶部

[英]Move view to the top of the screen with animation

I have following layout: 我有以下布局:

布局

Three EditText s in LinearLayout with layout_width = 0.33 . LinearLayout三个EditTextlayout_width = 0.33 When user put focus to one of those EditText s, two other should dissapear (maybe animation too) and last one should be moved to the top of the screen with some animation meanwhile soft keyboard is shown. 当用户将焦点放在其中一个EditText ,其他两个应该消失(也许也是动画),最后一个应该移动到带有某些动画的屏幕顶部,同时显示软键盘。 Result should looke like this: 结果应如下所示:

结果

Solution without animation is simple: 没有动画的解决方案很简单:

if(focusedView == mBlueEdit) {
  mRedEdit.setVisibility(View.GONE);
  mGreenEdit.setVisibility(View.GONE);

I can't figure out, when to start (it's too late start it after GONE is set at other views) and how to compute X and Y positions at start and at the end of animation. 我不知道何时开始(在其他视图上设置GONE之后再开始为时已晚)以及如何在动画的开始和结束时计算X和Y位置。 Thanks in advance for every hint. 预先感谢您的每一个提示。

不确定是否要查找它,但是可以通过将android:animateLayoutChanges="true"到LinearLayout中来创建自动动画。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM