Dialog底部彈出自定義view并且伴隨動(dòng)畫(huà)彈出和消失
原圖
點(diǎn)擊后
代碼
@Override public void onClick(View view) { switch (view.getId()) { //加號(hào)邏輯 case R.id.iv_more: AlertDialog.Builder builder = new android.app.AlertDialog.Builder(this,R.style.remind_dialog); LayoutInflater inflater = LayoutInflater.from(this); View mInflate = inflater.inflate(R.layout.activity_plus, null); iv_dialog_cacle = (ImageView) mInflate.findViewById(R.id.iv_cancel); iv_dialog_cacle.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog = builder.create(); dialog.show(); Window window = dialog.getWindow(); window.setGravity(Gravity.BOTTOM); window.setWindowAnimations(R.style.showdialog); window.setContentView(mInflate); WindowManager windowManager = getWindowManager(); Display display = windowManager.getDefaultDisplay(); WindowManager.LayoutParams lp= dialog.getWindow().getAttributes(); lp.width = (int)(display.getWidth()); //設(shè)置寬度 dialog.getWindow().setAttributes(lp); break; } }
remind_dialog
<style name="remind_dialog" parent="@android:style/Theme.Dialog"> <item name="android:windowFrame">@null</item> <item name="android:windowIsFloating">true</item> <item name="android:windowIsTranslucent">false</item> <item name="android:windowNoTitle">true</item> <item name="android:background">@android:color/transparent</item> <item name="android:windowBackground">@android:color/transparent</item> <item name="android:backgroundDimEnabled">true</item> <item name="android:windowAnimationStyle">@null</item> <item name="android:windowFullscreen">true</item> </style>
showdialog
<style name="showdialog" > <item name="@android:windowEnterAnimation">@anim/dialog_enter</item> <item name="@android:windowExitAnimation">@anim/dialog_exit</item> </style>
dialog_enter
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:toYDelta="0%" android:fillAfter="true" android:fromYDelta="100%p" /> </set>
dialog_exit
<?xml version="1.0" encoding="utf-8"?> <set xmlns:android="http://schemas.android.com/apk/res/android" > <translate android:duration="200" android:fromYDelta="0%" android:fillAfter="true" android:toYDelta="100%p" /> </set>
以上所述是小編給大家介紹的Dialog底部彈出自定義view并且伴隨動(dòng)畫(huà)彈出和消失,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
Android帶進(jìn)度條的文件上傳示例(使用AsyncTask異步任務(wù))
這篇文章主要介紹了Android帶進(jìn)度條的文件上傳示例(使用AsyncTask異步任務(wù)),使用起來(lái)比較方便,將幾個(gè)方法實(shí)現(xiàn)就行,感興趣的小伙伴們可以參考一下。2016-11-11Android6.0來(lái)電號(hào)碼與電話薄聯(lián)系人進(jìn)行匹配
這篇文章主要為大家詳細(xì)介紹了Android6.0來(lái)電號(hào)碼與電話薄聯(lián)系人進(jìn)行匹配的方法,感興趣的小伙伴們可以參考一下2016-07-07Android使用DrawerLayout仿QQ6.0雙側(cè)滑菜單
這篇文章主要為大家詳細(xì)介紹了Android使用DrawerLayout仿QQ6.0雙側(cè)滑菜單,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-08-08Android中的Selector的用法詳解及實(shí)例
這篇文章主要介紹了Android中的Selector的用法詳解及實(shí)例的相關(guān)資料,需要的朋友可以參考下2017-05-05Android 大文件切割與合并的實(shí)現(xiàn)代碼
這篇文章主要介紹了Android 大文件切割與合并,實(shí)現(xiàn)了很多發(fā)文件和視頻的切割,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-11-11Android View進(jìn)行手勢(shì)識(shí)別詳解
本文主要介紹 Android View進(jìn)行手勢(shì)識(shí)別,這里整理了相關(guān)資料和簡(jiǎn)單示例,有興趣的小伙伴可以參考下2016-08-08Android實(shí)現(xiàn)偵聽(tīng)電池狀態(tài)顯示、電量及充電動(dòng)態(tài)顯示的方法
這篇文章主要介紹了Android實(shí)現(xiàn)偵聽(tīng)電池狀態(tài)顯示、電量及充電動(dòng)態(tài)顯示的方法,非常實(shí)用的功能,需要的朋友可以參考下2014-09-09