scale_down.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="1.1"
android:fromYScale="1.1"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
scale_up.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<scale
android:pivotX="50%"
android:pivotY="50%"
android:fromXScale="0.9"
android:fromYScale="0.9"
android:toXScale="1.0"
android:toYScale="1.0" />
</set>
OnScaleDown in .java
LinearLayout mainLinear = findViewById(R.id.mainLinear);
Animation mainAnimation = AnimationUtils.loadAnimation(this, R.anim.anim_main_scale_down);
mainAnimation.setDuration(350);
mainAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
mainLinear.setScaleY(0.91f);
mainLinear.setScaleX(0.91f);
}
@Override
public void onAnimationEnd(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
OnScaleUp in .java
LinearLayout mainLinear = findViewById(R.id.mainLinear);
Animation mainAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.anim_main_scale_up);
mainAnimation.setDuration(350);
mainAnimation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
mainLinear.setScaleY(1f);
mainLinear.setScaleX(1f);
}
@Override
public void onAnimationEnd(Animation animation) {
ConstraintLayout backLinear = findViewById(R.id.activity_main);
backLinear.setBackgroundColor(Color.parseColor("#FFFFFFFF"));
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
'Android(Java)' 카테고리의 다른 글
activity.runOnUiThread() (0) | 2021.11.15 |
---|---|
Imageview drawable로 background 지정 후 맞추기 (0) | 2021.11.12 |
Intent로 메일 보내기, 웹링크 열기 (0) | 2021.11.12 |
ImageView 위에 컬러 오버레이 (0) | 2021.11.11 |
xml이 아닌 java코드에서 dp값으로 LayoutParams 설정 (0) | 2021.11.11 |