Reprint please indicate the source, thank you ~ ~
First of all, this is a tool-like blog, mainly to achieve popupwindow from the top or bottom or around the effect of the appearance. In order not to rewrite every time, so a method is taken out.
Private void Initpopuptwindow() {Layoutinflater layoutinflater = Layoutinflater.from ( This);//user_icon replace it with your own layoutView Popupwindow = layoutinflater.inflate (R.layout.user_icon,NULL); Mpopupwindow =NewPopupwindow (Popupwindow, layoutparams.match_parent, layoutparams.match_parent); Mpopupwindow.setoutsidetouchable (true); Mpopupwindow.setfocusable (true);//This property must be setMpopupwindow.setbackgrounddrawable (NewColordrawable (-000000));//This is the animation that sets the Popupwindow to appearMpopupwindow.setanimationstyle (R.style.anim_photo_select);//ll_root is the control you want to rely on, here is the layout of the control id,gravity is where you want to come out, here is the bottom. The next two bits are then offset by the X, y direction. Mpopupwindow.showatlocation (Ll_root, Gravity.bottom,0,0); }
R.style.anim_photo_select is the animation that appears in Popupwindow, which is written in the Styles.xml file:
name="anim_photo_select"> <itemname="android:windowEnterAnimation">@anim/photo_pop_in</item> <itemname="android:windowExitAnimation">@anim/photo_pop_out</item></style>
Then @anim/photo_pop_in and out are animated files that are placed in the Anim folder.
In
<?xml version= "1.0" encoding= "Utf-8"?><set xmlns:android="Http://schemas.android.com/apk/res/android" > <translate android:fromydelta="100%p" android:toydelta="0" android:duration="@android: Integer/config_mediumanimtime"/> <Alpha android:fromalpha="0.5" android:toalpha="1.0" Android:duration="@android: Integer/config_mediumanimtime" /> </Set>
Out
<?xml version= "1.0" encoding= "Utf-8"?><set xmlns:android="Http://schemas.android.com/apk/res/android" > <translate android:fromydelta="0%p" android:toydelta="100%p" android:duration="@android: Integer/config_mediumanimtime"/> <Alpha android:fromalpha="1.0" android:toalpha="0.5" android:duration="@android: Integer/config_mediumanimtime" /> </Set>
effect, because did not do the adaptation, so make a look at it, hahaha:
Basic use of Popupwindow