maoruibin / maoruibin/maoruibin.github.com
自定义 Dialog 显示隐藏动画
Open
Nobody has claimed this yet.
- Dominant language
- HTML
- Stars
- 22
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
默认的 Dialog 在调用 show 方法显示时是没有任何动画的,如果需要为 Dialog 添加显示隐藏动画,可使用如下方式:
1、初始化 Dialog 并设置 windowAnimations
Dialog dialog = new Dialog(this)
// or
Dialog dialog = new AlertDialog.Builder(this).create();
dialog.getWindow().getAttributes().windowAnimations = R.style.PauseDialogAnimation;
2、Dialog 动画资源配置
<style name="PauseDialogAnimation">
<item name="android:windowEnterAnimation">@anim/slide_up</item>
<item name="android:windowExitAnimation">@anim/slide_down</item>
</style>
3、动画文件
slide_up.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime">
<translate
android:fromYDelta="100%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toXDelta="0%p"/>
<alpha
android:fromAlpha="0"
android:toAlpha="1"/>
</set>
slide_down.xml
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="@android:integer/config_mediumAnimTime">
<translate
android:fromYDelta="0%p"
android:interpolator="@android:anim/accelerate_interpolator"
android:toYDelta="100%p"/>
<alpha
android:fromAlpha="1"
android:toAlpha="0"/>
</set>
Over~
参考
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No target file, test, or entry point is named. First inspect the blog's content structure and locate where this Chinese Dialog-animation article belongs; it is done when the supplied setup, XML style, and animation examples are published in the appropriate post.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- documentation, mobile-dev
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100