2013-03-28 1 views
0

간단한 버튼 이동 애니메이션을 만들었습니다. 그러나 버튼 변환 애니메이션이 끝나면 버튼 포커스는 버튼과 함께 움직이지 않았습니다. 초점은 여전히 ​​원래 위치에 있습니다.단추로 포커스 이동을 만드는 방법은 무엇입니까?

버튼으로 포커스 이동을 만드는 방법은 무엇입니까? 내 SDK의 API 레벨은 코드는 다음과 같다 (15)

입니다 :

package com.example.test; 

import android.os.Bundle; 
import android.app.Activity; 
import android.view.View; 
import android.view.animation.Animation; 
import android.view.animation.AnimationUtils; 
import android.widget.Button; 

public class MainActivity extends Activity { 

    private Button mButton; 

    private Animation mButtonAnimation; 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_main); 
     mButton = (Button) findViewById(R.id.button1); 
     mButton.setOnClickListener(new Button.OnClickListener() { 
      public void onClick(View v) { 
       mButtonAnimation.setFillAfter(true); 
       mButton.startAnimation(mButtonAnimation); 
      } 
     }); 

     mButtonAnimation = AnimationUtils.loadAnimation(this, R.anim.button_anim); 
    } 
} 

레이아웃 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <Button 
     android:id="@+id/button1" 
     style="?android:attr/buttonStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:text="Button" /> 

</RelativeLayout> 

button_anim.xml :

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" > 

    <translate 
     android:duration="500" 
     android:fromYDelta="0" 
     android:interpolator="@android:anim/linear_interpolator" 
     android:toYDelta="100" /> 
</set> 

답변

0

sdk

를 참조 fillAfter = true 시도
관련 문제