动画视图将堆叠在视图之上

时间:2015-11-02 03:54:20

标签: android android-animation

在我的Android应用中,我在<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:orientation="vertical"> <FrameLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/options_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:background="@color/light_gray" android:gravity="right" > <Button android:id="@+id/option_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingEnd="8dp" android:paddingRight="8dp" android:background="@color/transparent" android:text="@string/option_button" android:textColor="@color/white"/> </LinearLayout> <LinearLayout android:id="@+id/commentContainer" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@color/white" android:elevation="5dp" android:paddingLeft="16dp" android:paddingStart="16dp"> <EditText android:id="@+id/commentText" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="5" android:maxLines="1" android:inputType="textCapSentences" /> <ImageButton android:id="@+id/commentSubmit" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:background="@color/light_gray" android:textAllCaps="true" android:text="@string/submit_comment" android:src="@drawable/ic_send_white_24dp" android:textColor="@color/white"/> </LinearLayout> </FrameLayout> </LinearLayout> 的另一个视图后面有一个视图。我想有时为隐藏的视图设置动画,使其显示在显示的视图上方。这是我的XML:

commentText

理想情况下,当我开始输入options_container时,commentContainer会在options_container上方生成动画。似乎当我尝试动画view.animate().y(200); 时,没有真正发生的事情。只是为了检查,我试过了:

FrameLayout

我没有看到改变。这是因为我想要做的是在<form action="avfunc.php" method="POST" class="form-horizontal well"> <div id="updatediv"> <input type="submit" name="update" id="update" value="Update Reference" style="width:100px; display:none;" class="edit" /> </div> <fieldset> <div class="row"> <div class="col-lg-3"> </div> <div class="col-lg-6"> <?php $tsql = "select * from medtest"; $tstmt = $con->prepare($tsql); $tstmt->execute(); $tstmt->bind_result($mti,$mtn); $tstmt->store_result(); while ($tstmt->fetch()){ $d1= '<input type="checkbox" name="test" value="'.$mti.'" onClick="var e=document.getElementById("updatediv"); var s=document.getElementById("update"); e.removeChild(s) ; this.form.submit();">'.$mtn.'<br> '; echo $d1; } ?> <?php if($_POST['checkbox'] == "3"){ ?> <h4>Laboratory Examination</h4> <hr> <div class="row"> <div class="col-lg-6"> <div class="col-xs-2"> </div> <div class="col-xs-7"> <div><input type="checkbox" name="topic" value="1"><span>Complete Blood Count</span></div> <div><input type="checkbox" name="topic" value="2"><span>Blood Typing</span></div> <div><input type="checkbox" name="topic" value="3"><span>Urinalysis</span></div> <div><input type="checkbox" name="topic" value="4"><span>RPR/TPHA</span></div> <div><input type="checkbox" name="topic" value="5"><span>Hepatitis B screening</span></div> <div><input type="checkbox" name="topic" value="6"><span>Fasting Blood Sugar</span></div> <div><input type="checkbox" name="topic" value="7"><span>Creatinine</span></div> <div><input type="checkbox" name="topic" value="8"><span>Total Cholesterol(Low Cholesterol, High Cholesterol)</span></div> <div><input type="checkbox" name="topic" value="9"><span>Triglyceride</span></div> <div><input type="checkbox" name="topic" value="10"><span>VLDL</span></div> <div><input type="checkbox" name="topic" value="11"><span>Blood Uric Acid</span></div> <div><input type="checkbox" name="topic" value="12"><span>Anti-HAV Igm Screening</span></div> <div><input type="checkbox" name="topic" value="13"><span>Anti HBaAg</span></div> <div><input type="checkbox" name="topic" value="14"><span>Drug & Alcohol Test</span></div> <div><input type="checkbox" name="topic" value="15"><span>Stool Culture</span></div> </div <?php } ?> > <div class="col-xs-3"> </div> </div> <div class="col-lg-6"> </div> </div> </div> </div> <div class="col-lg-3"> </div> </div> 内部将视图叠加在另一个视图上(通过动画制作)?

1 个答案:

答案 0 :(得分:0)

首先,vishnus的评论是正确的,你需要调用start()来使动画有效。

但即使你这样做,它也行不通,因为代码只是沿着y轴移动视图。你真正需要的是animate()。z(),它在API 21中添加。