내 활동에 단추가 있고 TranslateAnimation을 사용하여 위치를 변경하고 있습니다.
나는 anim.setFillAfter (true)를 사용하고 있습니다. 결과 번역을 유지하려면 단추가 위치를 이동하지만 터치 영역은 동일하게 유지됩니다.
MainActivity.java
번역 된 단추가 올바른 결과를 제공하지 않습니다.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Animation anim=new TranslateAnimation(0, 100, 0, 0);
anim.setDuration(500);
anim.setFillAfter(true);
Button mybtn = (Button)findViewById(R.id.btn);
mybtn.startAnimation(anim);
}
public void myFunc(View v){
Toast.makeText(this, "btn clicked", Toast.LENGTH_SHORT).show();
}
}
에게 :
지금은이 버튼의 이전 위치에 접촉 오히려 작동하지 않는 버튼을 터치하면 다음
내 코드입니다 .. 그 리스너를 호출
activity_main.xml
<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"
tools:context=".MainActivity" >
<Button
android:id="@+id/btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
android:onClick="myFunc"/>
</RelativeLayout>
애니메이션을 제거하고 시도해 볼 수 있습니까? – lokoko
achually 나는 버튼을 다른 위치에 애니메이션으로 적용하고 거기에서 click 속성을 수행하기를 원합니다. –