内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

Android實(shí)現(xiàn)微博菜單彈出效果-創(chuàng)新互聯(lián)

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

10年積累的成都做網(wǎng)站、網(wǎng)站建設(shè)經(jīng)驗(yàn),可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有東莞免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。

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


1、截取當(dāng)前窗口,對圖片做高斯模糊處理,將處理后的圖片做popupwindow的背景圖片;
2、創(chuàng)建popupwindow,完成布局,這兒要注意:View的移動(dòng)范圍是由parent的大小決定的,就是只能在parent的范圍內(nèi)移動(dòng);
3、給買個(gè)View添加進(jìn)入動(dòng)畫,每個(gè)比前一個(gè)延期50ms播放動(dòng)畫,關(guān)閉窗口時(shí)相反;
4、為View的動(dòng)畫添加回彈插值器;

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<layout.getChildCount();i++){ 
   final View child = layout.getChildAt(i); 
   if(child.getId() == R.id.center_music_window_close){ 
    continue; 
   } 
   child.setOnClickListener(this); 
   child.setVisibility(View.INVISIBLE); 
   mHandler.postDelayed(new Runnable() { 
     
    @Override 
    public void run() { 
     child.setVisibility(View.VISIBLE); 
     ValueAnimator fadeAnim = ObjectAnimator.ofFloat(child, "translationY", 600, 0); 
     fadeAnim.setDuration(300); 
     KickBackAnimator kickAnimator = new KickBackAnimator(); 
     kickAnimator.setDuration(150); 
     fadeAnim.setEvaluator(kickAnimator); 
     fadeAnim.start(); 
    } 
   }, i * 50); 
  } 
   
 } 
 
 private void closeAnimation(ViewGroup layout){ 
  for(int i=0;i<layout.getChildCount();i++){ 
   final View child = layout.getChildAt(i); 
   if(child.getId() == R.id.center_music_window_close){ 
    continue; 
   } 
   child.setOnClickListener(this); 
   mHandler.postDelayed(new Runnable() { 
     
    @Override 
    public void run() { 
     child.setVisibility(View.VISIBLE); 
     ValueAnimator fadeAnim = ObjectAnimator.ofFloat(child, "translationY", 0, 600); 
     fadeAnim.setDuration(200); 
     KickBackAnimator kickAnimator = new KickBackAnimator(); 
     kickAnimator.setDuration(100); 
     fadeAnim.setEvaluator(kickAnimator); 
     fadeAnim.start(); 
     fadeAnim.addListener(new AnimatorListener() { 
       
      @Override 
      public void onAnimationStart(Animator animation) { 
       // TODO Auto-generated method stub 
        
      } 
       
      @Override 
      public void onAnimationRepeat(Animator animation) { 
       // TODO Auto-generated method stub 
        
      } 
       
      @Override 
      public void onAnimationEnd(Animator animation) { 
       child.setVisibility(View.INVISIBLE); 
      } 
       
      @Override 
      public void onAnimationCancel(Animator animation) { 
       // TODO Auto-generated method stub 
        
      } 
     }); 
    } 
   }, (layout.getChildCount()-i-1) * 30); 
    
   if(child.getId() == R.id.more_window_local){ 
    mHandler.postDelayed(new Runnable() { 
      
     @Override 
     public void run() { 
      dismiss(); 
     } 
    }, (layout.getChildCount()-i) * 30 + 80); 
   } 
  } 
   
 } 
 
 @Override 
 public void onClick(View v) { 
  switch (v.getId()) { 
  case R.id.more_window_local: 
   break; 
  case R.id.more_window_online: 
   break; 
  case R.id.more_window_delete: 
   break; 
  case R.id.more_window_collect: 
   break; 
  case R.id.more_window_auto: 
   break; 
  case R.id.more_window_external: 
   break; 
 
  default: 
   break; 
  } 
 } 
  
 public void destroy() { 
  if (null != overlay) { 
   overlay.recycle(); 
   overlay = null; 
   System.gc(); 
  } 
  if (null != mBitmap) { 
   mBitmap.recycle(); 
   mBitmap = null; 
   System.gc(); 
  } 
 } 
  
} 

分享標(biāo)題:Android實(shí)現(xiàn)微博菜單彈出效果-創(chuàng)新互聯(lián)
當(dāng)前URL:http://www.rwnh.cn/article32/esisc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)、電子商務(wù)、營銷型網(wǎng)站建設(shè)、動(dòng)態(tài)網(wǎng)站網(wǎng)頁設(shè)計(jì)公司、移動(dòng)網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站托管運(yùn)營
锡林浩特市| 琼中| 龙游县| 宜良县| 富蕴县| 晋城| 寿宁县| 南充市| 宁安市| 安溪县| 嫩江县| 兰考县| 科技| 辉县市| 贺兰县| 从江县| 蒙阴县| 英吉沙县| 唐海县| 廉江市| 慈溪市| 江陵县| 伊吾县| 白水县| 论坛| 沭阳县| 民乐县| 景东| 长汀县| 五家渠市| 锡林郭勒盟| 灵石县| 巴楚县| 兴城市| 静安区| 温宿县| 濉溪县| 华阴市| 来凤县| 延寿县| 雷山县|