Android實現(xiàn)蒙板效果
本文實例為大家分享了Android實現(xiàn)蒙板效果的相關(guān)代碼,供大家參考,具體內(nèi)容如下
1、不保留標題欄蒙板的實現(xiàn)
效果:
原理:
1、彈窗時,設(shè)置背景窗體的透明度
2、取消彈窗時,恢復(fù)背景窗體的透明度
關(guān)鍵代碼:
private void popupWindows(List<String> list){ //產(chǎn)生背景變暗效果 WindowManager.LayoutParams lp=getWindow().getAttributes(); lp.alpha = 0.4f; getWindow().setAttributes(lp); ......省略號...... mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() { @Override public void onDismiss() { WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.alpha = 1f; getWindow().setAttributes(lp); } }); ......省略號...... }
2、保留標題欄蒙板的實現(xiàn)
效果:
原理:
1、根據(jù)需求,設(shè)置蒙板布局大小。
2、彈窗時,顯示蒙板布局
2、取消彈窗時,隱藏蒙板布局
關(guān)鍵代碼:
1、蒙板布局實現(xiàn):
<!-- popup蒙板 --> <LinearLayout android:id="@+id/ll_popup_hide" android:layout_width="match_parent" android:background="@color/hide_bg" android:orientation="vertical" android:layout_height="match_parent"> </LinearLayout> <color name="hide_bg">#88323232</color>
2、代碼處理
ll_popup_hide.setVisibility(View.VISIBLE); //顯示蒙板 ll_popup_hide.setVisibility(View.INVISIBLE); //隱藏蒙板
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助。
相關(guān)文章
Android開發(fā)中Intent.Action各種常見的作用匯總
今天小編就為大家分享一篇關(guān)于Android開發(fā)中Intent.Action各種常見的作用匯總,小編覺得內(nèi)容挺不錯的,現(xiàn)在分享給大家,具有很好的參考價值,需要的朋友一起跟隨小編來看看吧2018-12-12android調(diào)用C語言實現(xiàn)內(nèi)存的讀取與修改的方法示例
這篇文章主要介紹了android調(diào)用C語言實現(xiàn)內(nèi)存的讀取與修改的方法示例,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03android studio集成ijkplayer的示例代碼
本篇文章主要介紹了android studio集成ijkplayer的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-09-09android計算器實現(xiàn)兩位數(shù)的加減乘除
這篇文章主要為大家詳細介紹了android計算器實現(xiàn)兩位數(shù)的加減乘除,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2020-03-03android FragmentTabhost實現(xiàn)導(dǎo)航分頁
這篇文章主要為大家詳細介紹了android FragmentTabhost實現(xiàn)導(dǎo)航分頁,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-08-08