//contentView : 气泡显示的内容 //width ,height : 宽高
PopupWindow popupWindow = new PopupWindow(contentView, LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT); //设置气泡弹出的执行动画样式 popupWindow.setAnimationStyle(R.style.DialogAnimaitonStyle); //显示气泡 //popupWindow.showAsDropDown(view);//将气泡显示在哪个控件的下方 //参数1:显示气泡的控件 //参数2,参数3:气泡距离显示气泡控件的左边和顶部边框的距离 popupWindow.showAsDropDown(view, 60, -view.getHeight());
<!-- 设置dialog的动画效果 --> <style name="DialogAnimaitonStyle"> <item name="android:windowEnterAnimation">@anim/input_method_enter</item> <item name="android:windowExitAnimation">@anim/input_method_exit</item> </style>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:shareInterpolator="false"> <translate android:fromYDelta="10%" android:toYDelta="0" android:interpolator="@interpolator/decelerate_quint" android:duration="@android:integer/config_shortAnimTime"/> <alpha android:fromAlpha="0.5" android:toAlpha="1.0" android:interpolator="@interpolator/decelerate_cubic" android:duration="@android:integer/config_shortAnimTime" /> </set>
时间: 2024-10-13 01:41:22