First, write an xml configuration file for popupWindow: <? Xml version = "1.0" encoding = "UTF-8"?> <LinearLayout xmlns: android = "http://schemas.android.com/apk/res/android" android: layout_width = "fill_parent" android: layout_height = "wrap_content"> <LinearLayout android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_marginLeft = "@ dimen/margin_max" android: layout_marginRight = "@ dimen/margin_max" android: background = "@ color/white" android: orientation = "vertical"> <! -- Main content --> <TextView android: id = "@ + id/diet_pop_tv1" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_marginLeft = "@ dimen/margin_max" android: text = "@ string/activity_aerobic" android: textColor = "@ color/string_bgwhite_main" android: textSize = "@ dimen/text_15"/> <! -- Main content sub --> <TextView android: id = "@ + id/diet_pop_tv2" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: text = "@ string/recipe_choose_exam" android: layout_marginLeft = "@ dimen/margin_max" android: textColor = "@ color/string_bgwhite_sub" android: textSize = "@ dimen/text_15"/> <! -- Second title --> <TextView android: id = "@ + id/diet_pop_tv3" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: background = "@ drawable/diet_pop_title" android: paddingLeft = "@ dimen/margin_max" android: layout_marginLeft = "@ dimen/margin_max" android: text = "@ string/example" android: textColor = "@ color/white" android: textSize = "@ dimen/text_15"/> <! -- Second content --> <TextView android: id = "@ + id/diet_pop_tv4" android: layout_width = "wrap_content" android: layout_height = "wrap_content" android: layout_marginLeft = "@ dimen/margin_max" android: text = "@ string/activity_aerobic_suggest" android: textColor = "@ color/string_bgwhite_main" android: textSize = "@ dimen/text_15"/> <ImageViewandroid: layout_width = "fill_parent" android: layout_height = "wrap_content" android: ScaleType = "fitStart" android: background = "@ drawable/popupshadow"/> </LinearLayout> --------- then -- Process popupWindow in the code, // new popupwindowView inflateView = getLayoutInflater (). inflate (R. layout. recipe_popwindow, null); // The xml file above, as the popupWindow view mPopupWindow = new PopupWindow (inflateView, LayoutParams. FILL_PARENT, LayoutParams. FILL_PARENT); mPopupWindow. setFocusable (false); mPopupWindow. set OutsideTouchable (true); mPopupWindow. setAnimationStyle (R. style. animationPreview); // set the animation effect to enter and exit for the popupWindow. Enter the animation to exit in the following configuration: Under the anim folder, enter the animation (from the lower right corner, from small to large): <? Xml version = "1.0" encoding = "UTF-8"?> <Set xmlns: android = "http://schemas.android.com/apk/res/android" android: interpolator = "@ android: anim/decelerate_interpolator"> <scale android: fromXScale = ". 1 "android: toXScale =" 1.0 "android: fromYScale = ". 1 "android: toYScale =" 1.0 "android: 20.tx =" 100% p "android: 0000ty =" 100% p "android: duration =" 500 "/> <alpha android: fromAlpha = "0" android: toAlpha = "1.0" android: duration = "@ android: integer/config_mediumAnim Time "/> </set> exit the animation (exit from the bottom right corner, from large to transparent): <? Xml version = "1.0" encoding = "UTF-8"?> <Set xmlns: android = "http://schemas.android.com/apk/res/android" android: interpolator = "@ android: anim/decelerate_interpolator" android: zAdjustment = "top"> <scale android: fromXScale = "1.0" android: toXScale = ". 5 "android: fromYScale =" 1.0 "android: toYScale = ". 5 "android: Short Tx =" 100% p "android: Short ty =" 100% p "android: duration =" @ android: integer/config_mediumAnimTime "/> <alpha android: fromAlpha = "1.0" android: t OAlpha = "0" android: duration = "@ android: integer/config_mediumAnimTime"/> </set> -------- configure style in the styles Folder: <style name = "AnimationPreview"> <item name = "android: windowEnterAnimation"> @ anim/zoomin </item> <item name = "android: export wexitanimation "> @ anim/zoomout </item> </style> ------- Finally, set popupWindow in the code to exit: public void openMenu (View v) {// System. out. println (view. getId () + "----- id --" + view. getBottom ()/ /+ "Bottom ----- view" + view. getTop (); if (! Flag) {// flag Initialization is false; // set position // mPopupWindow. showAtLocation (view, Gravity. LEFT, 0, 0); mPopupWindow. showAsDropDown (v, 0, 0); // view. findViewById (R. id. diet_sugget_ka ). setVisibility (View. INVISIBLE); flag = true;} else {mPopupWindow. dismiss (); flag = false ;}}