仿抖音注册Dialog实现
生活随笔
收集整理的這篇文章主要介紹了
仿抖音注册Dialog实现
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
今天將仿抖音注冊(cè)界面完成后接著便將注冊(cè)界面實(shí)現(xiàn)了,這里利用的是Dialog實(shí)現(xiàn)的
效果圖接下來介紹如何實(shí)現(xiàn)底部彈出Dialog
1.首先編寫動(dòng)畫文件
<!--tranlate_dialog_in.xml--> <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android"android:duration="200"android:fromXDelta="0"android:fromYDelta="100%"android:toXDelta="0"android:toYDelta="0"> </translate> <!--tranlate_dialog_out.xml--> <?xml version="1.0" encoding="utf-8"?> <translate xmlns:android="http://schemas.android.com/apk/res/android"android:duration="200"android:fromXDelta="0"android:fromYDelta="0"android:toXDelta="0"android:toYDelta="100%"> </translate>2.編寫Dialog的style
<style name="BottomDialog" parent="@style/Base.V7.Theme.AppCompat.Light.Dialog"><item name="android:windowNoTitle">true</item><item name="android:windowBackground">@android:color/transparent</item> </style> <style name="BottomDialog.Animation" parent="Animation.AppCompat.Dialog"><item name="android:windowEnterAnimation">@anim/tranlate_dialog_in</item><item name="android:windowExitAnimation">@anim/tranlate_dialog_out</item> </style>3.代碼中實(shí)現(xiàn)
Dialog bottomDialog = new Dialog(context, R.style.BottomDialog);bottomDialog.setContentView(contentView);ViewGroup.LayoutParams layoutParams = contentView.getLayoutParams();layoutParams.width = context.getResources().getDisplayMetrics().widthPixels;layoutParams.height=context.getResources().getDisplayMetrics().heightPixels;contentView.setLayoutParams(layoutParams);bottomDialog.getWindow().setGravity(Gravity.BOTTOM);bottomDialog.getWindow().setWindowAnimations(R.style.BottomDialog_Animation);bottomDialog.show();個(gè)人博客https://myml666.github.io
總結(jié)
以上是生活随笔為你收集整理的仿抖音注册Dialog实现的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: vsts~CI/CD实现自动化编译
- 下一篇: 解决Geoserver请求跨域的几种思路