各位大侠,求救!button移动后焦点不随之移动,该如何解决阿?
各位大侠,我做了一个简单的的button移动的动画,发现做完button的translate动画后,该button的焦点并没有随着button移动,还停留在原位置,我该如何让焦点跟随button一起移动阿? 我的sdk api level是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);
}
}
layout:
<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>
--------------------编程问答-------------------- 大家帮帮忙吧,多谢了 --------------------编程问答-------------------- 有人能解答吗? --------------------编程问答-------------------- 楼主问题解决了吗 --------------------编程问答-------------------- 释放焦点->移动->重新获取焦点
这样应该就可以了吧 --------------------编程问答-------------------- 怎么可能焦点不移动!! --------------------编程问答-------------------- 还真是他 娘的不会跟着移动 --------------------编程问答-------------------- animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
view.clearAnimation();
view.layout(left, top, left+width, top+height);
}
});
补充:移动开发 , Android