仿微信 个人头像修改 popPopupWindow实现Menus从底部弹出
2014-10-24 15:39
513 查看
先看效果图:
代码:自定义一个类 继承PopupWindows
单击弹出菜单:
动画效果:
fade_in:
fade_out:
代码:自定义一个类 继承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() { @Override public void onClick(View v) { // TODO Auto-generated method stub dismiss(); } }); // 导入布局 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() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub int 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 stub popMenus = 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" />
相关文章推荐
- 仿微信 个人头像修改 popPopupWindow实现Menus从底部弹出
- 【Android UI设计与开发】7.底部菜单栏(四)PopupWindow 实现显示仿腾讯新闻底部弹出菜单
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- PopupWindow实现右侧、左侧和底部弹出菜单
- 【Android UI设计与开发】7.底部菜单栏(四)PopupWindow 实现显示仿腾讯新闻底部弹出菜单
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- ios实现底部PopupWindow的示例代码(底部弹出菜单)
- Android PopupWindow实现右侧、左侧和底部弹出菜单
- iOS实现底部弹出PopupWindow效果 iOS改变背景透明效果
- android PopupWindow实现从底部弹出或滑出选择菜单或窗口
- Android自定义popupwindow实现ios中UC浏览器中长按图片弹出的PopupWindow效果
- Android之PopupWindow类似微信右上角的弹出菜单
- android PopupWindow 和 Activity弹出窗口实现方式
- PopWindow动画实现底部滑出菜单
- 底部菜单栏之Fragment+PopupWindow实现
- 使用Style实现的popwindow弹出和收起的动画效果
- PopupWindow实现弹出框功能
- 二进制数据流方式实现 个人头像的读取、上传、修改------善良公社项目