Android PopUpWindow的底部弹出和消失
来源:互联网 发布:中国综合国力知乎 编辑:程序博客网 时间:2024/04/26 05:00
实现的方法是:
private void show(){
View popLayout = LayoutInflater.from(this).inflate(R.layout.layout_pop_up_window,null);
ImageView ivPop = popLayout.findViewById(R.id.iv_pop);
ivPop.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Toast.makeText(MainActivity.this, "123456789", Toast.LENGTH_SHORT).show();
}
});
PopupWindow popupWindow = new PopupWindow(popLayout, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setTouchable(true);
popupWindow.setTouchInterceptor(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return false;
}
});
popupWindow.setFocusable(true);
popupWindow.setOutsideTouchable(true);
popupWindow.setBackgroundDrawable(new ColorDrawable(0));
popupWindow.setAnimationStyle(R.style.pop_anim);
popupWindow.showAtLocation(btnShow, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);
}
在values中的style文件中添加样式:
<style name="pop_anim" parent="android:Animation">
<item name="android:windowEnterAnimation">@anim/pop_enter_anim</item>
<item name="android:windowExitAnimation">@anim/pop_exit_anim</item>
</style>
在res文件夹下,新建anim文件夹,新建两个文件:
pop_enter_anim:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="200"
android:fromYDelta="100%p"
android:toYDelta="0" />
<alpha
android:duration="200"
android:fromAlpha="0.0"
android:toAlpha="1.0" />
</set>
pop_exit_anim:
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="1000"
android:fromYDelta="0"
android:toYDelta="50%p" />
<alpha
android:duration="1000"
android:fromAlpha="1.0"
android:toAlpha="0.0" />
</set>
阅读全文
0 0
- Android PopUpWindow的底部弹出和消失
- Android底部弹出的popupWindow
- popupwindow弹出和消失动画
- 从底部弹出的PopupWindow
- android 底部弹出选项,背景透明,PopupWindow的使用
- popupWindow定时消失和指定位置弹出
- Android PopupWindow实战仿QQ底部弹出
- Android 之从底部弹出PopupWindow
- android PopupWindow底部弹出gridview菜单
- Android从底部弹出一个PopupWindow
- Android从屏幕底部弹出popupWindow
- Android实现底部半透明弹出框PopUpWindow
- 实现从底部弹出的PopupWindow
- PopupWindow底部弹出
- PopupWindow底部弹出
- Popupwindow底部弹出
- PopupWindow底部弹出效果
- 底部弹出popUpWindow
- 分解质因数
- 正则表达式
- Course Schedule II
- Java Socket编程和TCP/IP协议
- 换了手机怎么恢复通讯录?换机之前你要了解的小技巧
- Android PopUpWindow的底部弹出和消失
- 在Simulink中使用方形还是圆行Sum(求和)模块呢
- C# Reflection 获取私有字段、方法
- 上传和下载文件
- python-error
- 牛客网---2016---搜狐马戏团
- 造轮子之ValueAnd
- 新零售时代线上线下的变革
- ROC曲线-阈值评价标准