真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Android實現(xiàn)微博菜單彈出效果

先上Android仿微博菜單彈出效果圖,這個截圖不是很流暢,大家可以下載apk試一下。

創(chuàng)新互聯(lián)一直秉承“誠信做人,踏實做事”的原則,不欺瞞客戶,是我們最起碼的底線! 以服務為基礎,以質(zhì)量求生存,以技術求發(fā)展,成交一個客戶多一個朋友!為您提供網(wǎng)站建設、成都網(wǎng)站制作、成都網(wǎng)頁設計、成都小程序開發(fā)、成都網(wǎng)站開發(fā)、成都網(wǎng)站制作、成都軟件開發(fā)、手機APP定制開發(fā)是成都本地專業(yè)的網(wǎng)站建設和網(wǎng)站設計公司,等你一起來見證!

 Android實現(xiàn)微博菜單彈出效果

說一下實現(xiàn)思路:

1、截取當前窗口,對圖片做高斯模糊處理,將處理后的圖片做popupwindow的背景圖片;
2、創(chuàng)建popupwindow,完成布局,這兒要注意:View的移動范圍是由parent的大小決定的,就是只能在parent的范圍內(nèi)移動;
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

 KickBackAnimator.Java回彈效果:

package com.jerome.weibo; 
 
import android.animation.TypeEvaluator; 
 
public class KickBackAnimator implements TypeEvaluator { 
 private final float s = 1.70158f; 
 float mDuration = 0f; 
 
 public void setDuration(float duration) { 
  mDuration = duration; 
 } 
 
 public Float evaluate(float fraction, Float startValue, Float endValue) { 
  float t = mDuration * fraction; 
  float b = startValue.floatValue(); 
  float c = endValue.floatValue() - startValue.floatValue(); 
  float d = mDuration; 
  float result = calculate(t, b, c, d); 
  return result; 
 } 
 
 public Float calculate(float t, float b, float c, float d) { 
  return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b; 
 } 
} 

代碼見github: https://github.com/gqdy365/WeiboPopupWindow

請大家star一下,我后面會持續(xù)更新;

下面是apk下載地址:WeiboPopupWindow

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持創(chuàng)新互聯(lián)。


名稱欄目:Android實現(xiàn)微博菜單彈出效果
轉(zhuǎn)載源于:http://weahome.cn/article/gjcioi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部