티스토리 뷰
어디든 비슷비슷하겠지만,
Android 어플이 있으면 동일한 iPhone 어플이 있기 마련이다.
UX를 고려하여 디자인이 설계 되는 경우도 있겠지만,
Android보다는 iPhone(iOS)이 훨씬 보기좋다? 라는 분들이 있어,
예전에 부득이하게 커스텀 다이얼로그를 만든적이 있어 기록한다.
iPhone에서 하단에서 뿅~ 하고 나타나는 Bottom Up 팝업 윈도우처럼 동작하게 해달라는 요청이 있어,
Base Dialog 아예 만들었다.
- opne.xml (애니메이션)
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromYDelta="100%"
android:toYDelta="0%"
android:duration="200"/>
</set>
- close.xml(애니메이션)
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/accelerate_interpolator">
<translate
android:fromYDelta="0%"
android:toYDelta= "100%"
android:duration="200"/>
</set>
- styles.xml
<style name="AnimationPopupStyle">
<item name="android:windowEnterAnimation">@anim/open</item>
<item name="android:windowExitAnimation">@anim/close</item>
</style>
- BaseDialog.java
public class BaseDialog extends Dialog {
protected Context mContext;
public BaseDialog(Context context, int layoutId ) {
super( context );
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView( layoutId );
this.mContext = context;
setCancelable( true );
setCanceledOnTouchOutside( true );
Window window = getWindow();
if( window != null ) {
// 백그라운드 투명
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
WindowManager.LayoutParams params = window.getAttributes();
// 화면에 가득 차도록
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.MATCH_PARENT;
// 열기&닫기 시 애니메이션 설정
params.windowAnimations = R.style.AnimationPopupStyle;
window.setAttributes( params );
// UI 하단 정렬
window.setGravity( Gravity.BOTTOM );
}
}
}
사용시 위 BaseDialog 클래스를 상속받아 구현하고 싶은 Dialog를 만들면 된다.
위 open, close 애니메이션을 변경하고,
Dialog의 setGravity 값을 조정하므로써, 팝업 뜨는 방식을 다양하게 결정할 수 있다~
'Android Memo' 카테고리의 다른 글
Glide 모듈을 사용 한 비동기 이미지를 포함하는 노티피케이션 띄우기 (0) | 2018.12.07 |
---|---|
Android ViewPager 내부 View에 클릭 이벤트가 있을 경우 해당 View 페이징이 안되는 증상. (0) | 2018.11.16 |
안드로이드 Sol Prime 단말 fontFamily 설정 오류 (0) | 2018.11.06 |
Android AnimationDrawable OneShot 옵션 시 Finish 타이밍 캐치하기 (0) | 2018.10.24 |
Android Oreo 백그라운드에서 서비스 실행에 관한 고찰... (0) | 2018.10.24 |
- Total
- Today
- Yesterday
- android o
- buildToolsVersion 31.0.0
- notification
- targetSdkVersion 31
- 문자열
- Android Custom Dialog
- fontFamily
- glide
- AnimationDrawable
- ViewPager
- FrameAnimation
- Android 더블 클릭
- startForegroundService
- String append
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |