728x90
반응형
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:fromYDelta="100%"
android:toYDelta="0"
android:duration="500"/>
</set>
res / values / themes.xml
<style name="FullWidth.Dialog" parent="Theme.AppCompat.DayNight.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowFullscreen">false</item>
<item name="android:background">@android:color/transparent</item>
<item name="android:windowBackground">@android:color/transparent</item>
<!--<item name="android:windowAnimationStyle">@style/DialogAnimation</item>-->
</style>
Test.class
package kr.co.eoapps.test_module;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.app.Dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Point;
import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.view.Display;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
public class Test extends Dialog {
Context mContext;
Animation slideUp;
Animation slideDown;
boolean isDown = true;
public Test(@NonNull Context context) {
super(context);
this.mContext = context;
slideUp = AnimationUtils.loadAnimation(mContext, R.anim.s_up);
slideUp.setAnimationListener(animationListener);
slideDown = AnimationUtils.loadAnimation(mContext, R.anim.s_down);
slideDown.setAnimationListener(animationListener);
}
public Test(@NonNull Context context, int themeResId) {
super(context, themeResId);
this.mContext = context;
slideUp = AnimationUtils.loadAnimation(mContext, R.anim.s_up);
slideUp.setAnimationListener(animationListener);
slideDown = AnimationUtils.loadAnimation(mContext, R.anim.s_down);
slideDown.setAnimationListener(animationListener);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
Display display = getWindow().getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getRealSize(size); // or getSize(size)
int width = size.x;
int height = size.y;
getWindow().setLayout(width,500);
*/
requestWindowFeature(Window.FEATURE_NO_TITLE); //상단 타이틀 제거
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); //배경 투명
setCanceledOnTouchOutside(false); //배경 터치 닫기 기능 사용유무
setContentView(R.layout.activity_test);
LinearLayout layout = (LinearLayout)findViewById(R.id.layout_test);
layout.startAnimation(slideUp);
}
Animation.AnimationListener animationListener = new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
if (!isDown) {
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
};
}
다이얼로그 호출
Test dialog = new Test(context,R.style.FullWidth_Dialog);
dialog.show();
+ 애니메이션 효과
res / anim / s_up.xml
728x90
반응형