网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Android实现微博菜单弹出效果-创新互联

先上Android仿微博菜单弹出效果图,这个截图不是很流畅,大家可以下载apk试一下。

10年积累的成都做网站、网站建设经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先网站制作后付款的网站建设流程,更有东莞免费网站建设让你可以放心的选择与我们合作。

说一下实现思路:


1、截取当前窗口,对图片做高斯模糊处理,将处理后的图片做popupwindow的背景图片;
2、创建popupwindow,完成布局,这儿要注意:View的移动范围是由parent的大小决定的,就是只能在parent的范围内移动;
3、给买个View添加进入动画,每个比前一个延期50ms播放动画,关闭窗口时相反;
4、为View的动画添加回弹插值器;

MoreWindow.java窗口


package com.jerome.weibo; 
 
import android.animation.Animator; 
import android.animation.Animator.AnimatorListener; 
import android.animation.ObjectAnimator; 
import android.animation.ValueAnimator; 
import android.app.Activity; 
import android.graphics.Bitmap; 
import android.graphics.Canvas; 
import android.graphics.Paint; 
import android.graphics.Rect; 
import android.graphics.drawable.BitmapDrawable; 
import android.os.Handler; 
import android.util.DisplayMetrics; 
import android.util.Log; 
import android.view.Gravity; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.view.ViewGroup; 
import android.view.animation.Animation; 
import android.view.animation.Animation.AnimationListener; 
import android.view.animation.AnimationSet; 
import android.view.animation.TranslateAnimation; 
import android.widget.ImageView; 
import android.widget.PopupWindow; 
import android.widget.RelativeLayout; 
import android.widget.RelativeLayout.LayoutParams; 
 
public class MoreWindow extends PopupWindow implements OnClickListener{ 
 
 private String TAG = MoreWindow.class.getSimpleName(); 
 Activity mContext; 
 private int mWidth; 
 private int mHeight; 
 private int statusBarHeight ; 
 private Bitmap mBitmap= null; 
 private Bitmap overlay = null; 
  
 private Handler mHandler = new Handler(); 
 
 public MoreWindow(Activity context) { 
  mContext = context; 
 } 
 
 public void init() { 
  Rect frame = new Rect(); 
  mContext.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); 
  statusBarHeight = frame.top; 
  DisplayMetrics metrics = new DisplayMetrics(); 
  mContext.getWindowManager().getDefaultDisplay() 
    .getMetrics(metrics); 
  mWidth = metrics.widthPixels; 
  mHeight = metrics.heightPixels; 
   
  setWidth(mWidth); 
  setHeight(mHeight); 
 } 
  
 private Bitmap blur() { 
  if (null != overlay) { 
   return overlay; 
  } 
  long startMs = System.currentTimeMillis(); 
 
  View view = mContext.getWindow().getDecorView(); 
  view.setDrawingCacheEnabled(true); 
  view.buildDrawingCache(true); 
  mBitmap = view.getDrawingCache(); 
   
  float scaleFactor = 8;//图片缩放比例; 
  float radius = 10;//模糊程度 
  int width = mBitmap.getWidth(); 
  int height = mBitmap.getHeight(); 
 
  overlay = Bitmap.createBitmap((int) (width / scaleFactor),(int) (height / scaleFactor),Bitmap.Config.ARGB_8888); 
  Canvas canvas = new Canvas(overlay); 
  canvas.scale(1 / scaleFactor, 1 / scaleFactor); 
  Paint paint = new Paint(); 
  paint.setFlags(Paint.FILTER_BITMAP_FLAG); 
  canvas.drawBitmap(mBitmap, 0, 0, paint); 
 
  overlay = FastBlur.doBlur(overlay, (int) radius, true); 
  Log.i(TAG, "blur time is:"+(System.currentTimeMillis() - startMs)); 
  return overlay; 
 } 
  
 private Animation showAnimation1(final View view,int fromY ,int toY) { 
  AnimationSet set = new AnimationSet(true); 
  TranslateAnimation go = new TranslateAnimation(0, 0, fromY, toY); 
  go.setDuration(300); 
  TranslateAnimation go1 = new TranslateAnimation(0, 0, -10, 2); 
  go1.setDuration(100); 
  go1.setStartOffset(250); 
  set.addAnimation(go1); 
  set.addAnimation(go); 
 
  set.setAnimationListener(new AnimationListener() { 
 
   @Override 
   public void onAnimationEnd(Animation animation) { 
   } 
 
   @Override 
   public void onAnimationRepeat(Animation animation) { 
 
   } 
 
   @Override 
   public void onAnimationStart(Animation animation) { 
 
   } 
 
  }); 
  return set; 
 } 
  
 
 public void showMoreWindow(View anchor,int bottomMargin) { 
  final RelativeLayout layout = (RelativeLayout)LayoutInflater.from(mContext).inflate(R.layout.center_music_more_window, null); 
  setContentView(layout); 
   
  ImageView close= (ImageView)layout.findViewById(R.id.center_music_window_close); 
  android.widget.RelativeLayout.LayoutParams params =new android.widget.RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT); 
  params.bottomMargin = bottomMargin; 
  params.addRule(RelativeLayout.BELOW, R.id.more_window_auto); 
  params.addRule(RelativeLayout.RIGHT_OF, R.id.more_window_collect); 
  params.topMargin = 200; 
  params.leftMargin = 18; 
  close.setLayoutParams(params); 
   
  close.setOnClickListener(new OnClickListener() { 
 
   @Override 
   public void onClick(View v) { 
    if (isShowing()) { 
     closeAnimation(layout); 
    } 
   } 
 
  }); 
   
  showAnimation(layout); 
  setBackgroundDrawable(new BitmapDrawable(mContext.getResources(), blur())); 
  setOutsideTouchable(true); 
  setFocusable(true); 
  showAtLocation(anchor, Gravity.BOTTOM, 0, statusBarHeight); 
 } 
 
 private void showAnimation(ViewGroup layout){ 
  for(int i=0;i            
分享文章:Android实现微博菜单弹出效果-创新互联
文章分享:http://bjjierui.cn/article/esisc.html

其他资讯