简体   繁体   English

Android动画LinearLayout

[英]Android animation linearlayout

I have got a linearlayout form. 我有一个线性布局表格。 This form has got a 2 fields. 该表格有2个字段。 I would like get this effect: 我想要这种效果:

Two fields, one is hidden (under top bar). 有两个字段,其中一个是隐藏的(在顶部栏下方)。 When i click button 'ok' this linear layout go down and display next field (hidden field). 当我单击“确定”按钮时,此线性布局向下并显示下一个字段(隐藏字段)。 How get this effect? 如何获得这种效果?

在此处输入图片说明

  • Place your two fields inside a RelativeLayout . 将您的两个字段放在RelativeLayout
  • Set the property android:visibility="gone" for the first of them. 为其设置第一个属性android:visibility="gone"
  • Set the property android:layout_below="@id/yourFirstField" for the second. 设置第二个属性android:layout_below="@id/yourFirstField"
  • Add onClickListener to the button and, in the body on the listener in your Java class, change the visibility of the first field to visible (I guess it's an EditText, so EditText.VISIBLE ) onClickListener添加到按钮,然后在Java类的侦听器的主体中,将第一个字段的可见性更改为visible(我猜它是一个EditText,所以是EditText.VISIBLE
  • If you want to get a nice effect for hiding/showing elements, add android:animateLayoutChanges="true" to your RelativeLayout (the container of both items). 如果您想获得很好的隐藏/显示元素效果,请将android:animateLayoutChanges="true"到您的RelativeLayout(两个项目的容器)中。

This should work!! 这应该工作!! I hope this helps!! 我希望这有帮助!!

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

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