2014-03-02 39 views
0

這是我的佈局的Android動畫元素和右上

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       android:orientation="vertical" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:gravity="center" 
     > 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="horizontal" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:gravity="center" 
        android:id="@+id/lin1" 
      > 
     <TextView 
       android:layout_width="wrap_content" 
       android:textSize="40sp" 
       android:text="Score:0" 
       android:id="@+id/textView" 
       android:layout_height="wrap_content" 
       android:layout_marginRight="10sp"/> 
     <Chronometer 
       android:id="@+id/chronometer" 
       android:format="%s" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textSize="40sp" 
       android:layout_marginLeft="10sp" 
       /> 
    </LinearLayout> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:orientation="horizontal" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:gravity="center" 
        android:layout_below="@+id/lin1" 
      > 
     <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Start Quiz Now" 
       android:layout_gravity="center" 
       android:gravity="center" 
       android:layout_centerHorizontal="true" 
       android:id="@+id/startQuizButton" 
       /> 
    </LinearLayout> 

    <FrameLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/frameLayout"></FrameLayout> 

</RelativeLayout> 

這是什麼樣子:enter image description here

於是就按一下按鈕,我想比分文字框移到屏幕的左上方,並將計時器移到屏幕的右上方。此外,該按鈕將消失,在framelayout中將出現一個包含測驗問題的片段。

我已經試過了得分文本框下面的動畫,但它不會移動到任何更多左:

<?xml version="1.0" encoding="utf-8"?> 

<set xmlns:android="http://schemas.android.com/apk/res/android"> 
    <translate 
      android:fromXDelta="100%" 
      android:toXDelta="0%p" 
      android:duration="900" 
      > 
    </translate> 
      
</set> 

另外,就算我得到了一些動畫工作,盒子回來它在動畫結束後的初始大小。我希望它留在那裏。 我已經做了很多關於值的命中和試用,但無法讓它工作。請幫忙。

回答

0

嘗試將toX值更改爲「0dp」並添加fillAfter =「true」。檢查http://developer.android.com/reference/android/view/animation/Animation.html獲得更多動畫幫助

+0

Android資源包裝:[fq] /Users/rajat.khandelwal/fq/res/Android Resource Packaging:[fq] /Users/rajat.khandelwal/fq/res/anim/move_to_top_left。 xml:4:error:錯誤:不允許使用維度類型('toXDelta'值爲'0dp')anim/move_to_top_left.xml:4:錯誤:錯誤:不允許使用維度類型('toXDelta' )。 – prongs