반응형
회원가입 및 로그인 등 입력 받는 창을 만들다 보면 editText를 흔드는 애니메이션이 필요할 때가 있다
그럴 때에는 애니메이션을 만들어서 코드로도 쉽게 사용할 수 있게 하자.
1. cycle.xml
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="10"/>
총 10번 editText를 흔든다.
2. shake.xml
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="10" android:duration="500"
android:interpolator="@anim/cycle" />
0.5초 동안 흔든다
3. Java
// animation
Animation animation = AnimationUtils.loadAnimation(ShakeActivity.this, R.anim.shake);
// editText 에 적용 후 포커스를 준다
editText.startAnimation(animation);
editText.requestFocus();
반응형
'Android' 카테고리의 다른 글
[Android] 다른 영역 터치 시 키보드 숨기기 (0) | 2021.03.15 |
---|---|
[Android] Material Theme 사용 시 Button 레이아웃 (0) | 2020.10.07 |
[Android] 키보드 사용 시 화면 스크롤 컨트롤 (0) | 2020.09.14 |
[Android] ImageView Animation (0) | 2020.06.03 |
[Android] TelephonyManager 통화상태 확인하기 (0) | 2020.06.02 |