仿微信 个人头像修改 popPopupWindow实现Menus从底部弹出
来源:互联网 发布:ssh使用的端口号是 编辑:程序博客网 时间:2024/05/17 12:25
先看效果图:
代码:自定义一个类 继承PopupWindows
package com.yuan.keyanhelper.view;import io.vov.vitamio.activity.InitActivity;import java.util.List;import com.example.keyanhelper.R;import com.example.keyanhelper.R.layout;import android.app.Activity;import android.content.Context;import android.graphics.drawable.ColorDrawable;import android.view.LayoutInflater;import android.view.MotionEvent;import android.view.View;import android.view.View.OnClickListener;import android.view.View.OnTouchListener;import android.view.ViewGroup.LayoutParams;import android.widget.Button;import android.widget.PopupWindow;import android.widget.AdapterView.OnItemClickListener;public class PhotoPopupWindows extends PopupWindow {private View mMenuView; // PopupWindow 菜单布局private Context context; // 上下文参数private OnClickListener myOnClick; // PopupWindow 菜单 空间单击事件public PhotoPopupWindows(Activity context, OnClickListener myOnClick) {super(context);this.context = context;this.myOnClick = myOnClick;Init();}private void Init() {// TODO Auto-generated method stub// PopupWindow 导入LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);mMenuView = inflater.inflate(R.layout.popitem_alter_icon, null);Button btn_camera = (Button) mMenuView.findViewById(R.id.btn_alter_pic_camera);Button btn_photo = (Button) mMenuView.findViewById(R.id.btn_alter_pic_photo);Button btn_cancel = (Button) mMenuView.findViewById(R.id.btn_alter_exit);btn_camera.setOnClickListener(myOnClick);btn_cancel.setOnClickListener(myOnClick);btn_photo.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubdismiss();}});// 导入布局this.setContentView(mMenuView);// 设置动画效果this.setAnimationStyle(R.style.AnimationFade);this.setWidth(LayoutParams.FILL_PARENT);this.setHeight(LayoutParams.WRAP_CONTENT);// 设置可触this.setFocusable(true);ColorDrawable dw = new ColorDrawable(0x0000000);this.setBackgroundDrawable(dw);// 单击弹出窗以外处 关闭弹出窗mMenuView.setOnTouchListener(new OnTouchListener() {@Overridepublic boolean onTouch(View v, MotionEvent event) {// TODO Auto-generated method stubint height = mMenuView.findViewById(R.id.ll_pop).getTop();int y = (int) event.getY();if (event.getAction() == MotionEvent.ACTION_UP) {if (y < height) {dismiss();}}return true;}});}}
单击弹出菜单:
private void showPopMenu() {// TODO Auto-generated method stubpopMenus = new PhotoPopupWindows(this, myMenusOnClick);popMenus.showAtLocation(this.findViewById(R.id.ll_person_info),Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0);}
动画效果:
fade_in:
<translate android:duration="200" android:fromYDelta="100%p" android:toYDelta="0" /> <alpha android:duration="200" android:fromAlpha="0.0" android:toAlpha="1.0" />
fade_out:
<translate android:duration="200" android:fromYDelta="0" android:toYDelta="50%p" /> <alpha android:duration="200" android:fromAlpha="1.0" android:toAlpha="0.0" />
0 0
- 仿微信 个人头像修改 popPopupWindow实现Menus从底部弹出
- 仿微信 个人头像修改 popPopupWindow实现Menus从底部弹出
- Android Demo---实现从底部弹出窗口
- 自定义PopupWindow轻松实现从底部弹出
- 实现从底部弹出的PopupWindow
- DialogFragment从底部弹出
- PopupWindow从底部弹出
- 从底部弹出框
- ImageLoader 修改个人头像
- 如何修改CSDN个人头像
- Android实现从底部弹出的Dialog(一)
- Android实现从底部弹出的Dialog(二)
- android Activity实现从底部弹出菜单或窗口
- 使用DialogFragment实现支付宝支付从底部弹出效果
- 实现从屏幕底部向上弹出新窗口的思路
- Activity从底部向上半透明弹出效果实现
- iOS 手动实现modal效果,从底部弹出一个控制器
- 实现一个从底部向上弹出的菜单栏
- jquery 校验
- Java学习笔记之 IO包 字节流
- ijkplayer学习系列之环境搭建
- Java父类引用指向子类对象静态绑定和动态绑定问题
- Python: How to Sort a List
- 仿微信 个人头像修改 popPopupWindow实现Menus从底部弹出
- FPGA学习步骤,我的体会
- log file parallel write&&log buffer space
- 计算三种缺页中断的缺页数,缺页率和命中率FIFO,LRU,OPT
- xcode6中自动布局autolayout和sizeclass的使用
- 一些想法
- (十一)洞悉linux下的Netfilter&iptables:iptables命令行工具源码解析【上】
- Java多线程之线程池
- Android工程名更改