亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Android實(shí)現(xiàn)毛玻璃效果彈出菜單動(dòng)畫

 更新時(shí)間:2022年08月10日 10:08:12   作者:lvshaorong  
這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)毛玻璃效果彈出菜單動(dòng)畫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了Android實(shí)現(xiàn)毛玻璃效果彈出菜單動(dòng)畫的具體代碼,供大家參考,具體內(nèi)容如下

仿ios上屏幕下方向上滑出來(lái)的一個(gè)模糊菜單,效果如下

原理很簡(jiǎn)單,頁(yè)面上原來(lái)有一個(gè)gone的framelayout,調(diào)用方法讓它彈出的時(shí)候加了一個(gè)位移動(dòng)畫,讓它從底部出來(lái),出來(lái)的時(shí)候給這個(gè)framelayout里的一個(gè)imageView設(shè)置一個(gè)模糊后的截屏圖片,并且這個(gè)圖片也加一個(gè)相同時(shí)間的反方向位移動(dòng)畫,這個(gè)demo里用到的Blur模糊類和自定義imageView可以去我前兩篇博客上找到.

這里面用的控件的大小等全部是動(dòng)態(tài)計(jì)算的,不必?fù)?dān)心屏幕適配的問(wèn)題

activity的布局如下

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
? ? xmlns:tools="http://schemas.android.com/tools"
? ? android:id="@+id/window"
? ? android:layout_width="match_parent"
? ? android:layout_height="match_parent"
? ? tools:context="com.npi.blureffect.DialogActivity" >
?
? ? <TextView
? ? ? ? android:id="@+id/textView1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:text="@string/hello_world" />
? ? ?<RatingBar
? ? ? ? android:id="@+id/ratingBar1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignLeft="@+id/textView1"
? ? ? ? android:layout_below="@+id/textView1"
? ? ? ? android:layout_marginTop="124dp" />
?
? ? <Switch
? ? ? ? android:id="@+id/switch1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignLeft="@+id/ratingBar1"
? ? ? ? android:layout_below="@+id/ratingBar1"
? ? ? ? android:layout_marginLeft="24dp"
? ? ? ? android:layout_marginTop="81dp"
? ? ? ? android:text="Switch" />
?
? ? <Button
? ? ? ? android:id="@+id/button1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignRight="@+id/ratingBar1"
? ? ? ? android:layout_below="@+id/ratingBar1"
? ? ? ? android:text="Button" />
?
? ? <Button
? ? ? ? android:id="@+id/button2"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignBottom="@+id/ratingBar1"
? ? ? ? android:layout_alignLeft="@+id/switch1"
? ? ? ? android:layout_marginBottom="52dp"
? ? ? ? android:text="Button" />
?
? ? <TextView
? ? ? ? android:id="@+id/textView2"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignBottom="@+id/button1"
? ? ? ? android:layout_alignLeft="@+id/ratingBar1"
? ? ? ? android:text="Large Text"
? ? ? ? android:textAppearance="?android:attr/textAppearanceLarge" />
?
? ? <ProgressBar
? ? ? ? android:id="@+id/progressBar1"
? ? ? ? style="?android:attr/progressBarStyleHorizontal"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignParentBottom="true"
? ? ? ? android:layout_marginBottom="49dp"
? ? ? ? android:layout_toLeftOf="@+id/button1" />
?
? ? <ProgressBar
? ? ? ? android:id="@+id/progressBar2"
? ? ? ? style="?android:attr/progressBarStyleLarge"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_below="@+id/switch1"
? ? ? ? android:layout_toRightOf="@+id/switch1" />
?
? ? <RadioButton
? ? ? ? android:id="@+id/radioButton1"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_above="@+id/progressBar1"
? ? ? ? android:layout_alignLeft="@+id/switch1"
? ? ? ? android:text="RadioButton" />
?
? ? <Button
? ? ? ? android:id="@+id/button3"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="wrap_content"
? ? ? ? android:layout_alignLeft="@+id/progressBar2"
? ? ? ? android:layout_below="@+id/progressBar2"
? ? ? ? android:text="Button" />
?
? ? <FrameLayout
? ? ? ? android:id="@+id/bottom_menu"
? ? ? ? android:layout_width="wrap_content"
? ? ? ? android:layout_height="200dp"
? ? ? ? android:layout_alignParentBottom="true"
? ? ? ? android:layout_alignParentLeft="true"
? ? ? ? android:layout_alignParentRight="true"
? ? ? ? android:background="#eeeeee"
? ? ? ? android:visibility="gone" >
?
? ? ? ? <com.npi.blureffect.ScrollableImageView
? ? ? ? ? ? android:id="@+id/bottom_back"
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="match_parent"
? ? ? ? ? ? android:src="@drawable/abs__ab_share_pack_holo_light" />
?
? ? ? ? <LinearLayout
? ? ? ? ? ? android:layout_width="match_parent"
? ? ? ? ? ? android:layout_height="wrap_content" >
?
? ? ? ? ? ? <ImageView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:src="@drawable/abs__ic_voice_search" />
?
? ? ? ? ? ? <ImageView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:src="@drawable/abs__ic_voice_search" />
?
? ? ? ? ? ? <ImageView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:src="@drawable/abs__ic_voice_search" />
?
? ? ? ? ? ? <ImageView
? ? ? ? ? ? ? ? android:layout_width="wrap_content"
? ? ? ? ? ? ? ? android:layout_height="wrap_content"
? ? ? ? ? ? ? ? android:layout_weight="1"
? ? ? ? ? ? ? ? android:src="@drawable/abs__ic_voice_search" />
?
? ? ? ? </LinearLayout>
?
? ? </FrameLayout>
?
? ? <ImageView
? ? ? ? android:id="@+id/background"
? ? ? ? android:layout_width="match_parent"
? ? ? ? android:layout_height="match_parent"
? ? ? ? android:background="#fff"
? ? ? ? android:visibility="gone" />
?
</RelativeLayout>

activity如下

package com.npi.blureffect;
?
import java.util.TimerTask;
?
?
import android.app.Activity;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.RelativeLayout;
import android.widget.TextView;
?
public class DialogActivity extends Activity {
TextView textView1;
RelativeLayout window;
ImageView background;
FrameLayout bottomMenu;
Button button2;
Button button1;
ScrollableImageView bottomBack;
?? ?@Override
?? ?protected void onCreate(Bundle savedInstanceState) {
?? ??? ?super.onCreate(savedInstanceState);
?? ??? ?setContentView(R.layout.activity_dialog);
?? ??? ?textView1 = (TextView) findViewById(R.id.textView1);
?? ??? ?window = (RelativeLayout)findViewById(R.id.window);
?? ??? ?background = (ImageView) findViewById(R.id.background);
?? ??? ?bottomMenu = (FrameLayout) findViewById(R.id.bottom_menu);
?? ??? ?button2 = (Button) findViewById(R.id.button2);
?? ??? ?bottomBack = (ScrollableImageView) findViewById(R.id.bottom_back);
?? ??? ?button1 = (Button) findViewById(R.id.button1);
?? ??? ?button2.setOnClickListener(new OnClickListener() {
?? ??? ??? ?
?? ??? ??? ?@Override
?? ??? ??? ?public void onClick(View v) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?showBottomMenu(window,500);
?? ??? ??? ?}
?? ??? ?});
?? ??? ?button1.setOnClickListener(new OnClickListener() {
?? ??? ??? ?
?? ??? ??? ?@Override
?? ??? ??? ?public void onClick(View v) {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?hideBottomMenu(window, 500);
?? ??? ??? ?}
?? ??? ?});
?? ?}
?
? ?public void showBottomMenu(View layout,final int duration){
?? ? //對(duì)當(dāng)前頁(yè)面進(jìn)行截屏
?? ? ?? ??? ?layout.setDrawingCacheEnabled(true); ?
?? ? ?? ??? ?layout.buildDrawingCache(); ?//啟用DrawingCache并創(chuàng)建位圖 ?
?? ? ?? ??? ?Bitmap screen = Bitmap.createBitmap(layout.getDrawingCache()); //創(chuàng)建一個(gè)DrawingCache的拷貝,因?yàn)镈rawingCache得到的位圖在禁用后會(huì)被回收 ?
?? ? ?? ??? ?layout.setDrawingCacheEnabled(false); ?//禁用DrawingCahce否則會(huì)影響性能 ?
?? ? ? ? ?? ?
?? ? ?? ??? ?//將截屏進(jìn)行模糊
?? ? ?? ??? ?screen = Blur.fastblur(this, screen, 10);
?? ? ?? ??? ?bottomBack.setoriginalImage(screen);
?? ? ?? ??? ?
?? ? ?? ??? ?
?? ? ? bottomMenu.setAlpha(0);//在動(dòng)畫開(kāi)啟之后再可見(jiàn),否則會(huì)有殘影
?? ? ? bottomMenu.setVisibility(View.VISIBLE);
?? ? ? bottomMenu.post(new Runnable() {
?? ??? ?
?? ??? ?@Override
?? ??? ?public void run() {
?? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ?Animation animation = new TranslateAnimation(0, 0, bottomMenu.getHeight(), 0);//這里彈出框的高度的dp需要事先寫死
?? ??? ??? ?bottomBack.handleScroll(bottomBack.getOriginalImage().getHeight()-bottomMenu.getHeight(), 0);
?? ??? ??? ?Animation backgroundAnimation = new TranslateAnimation(0,0,-bottomBack.getHeight(),0);
?? ??? ??? ?backgroundAnimation.setDuration(duration);
?? ??? ??? ?bottomBack.startAnimation(backgroundAnimation);
?? ??? ??? ?animation.setAnimationListener(new AnimationListener() {
?? ??? ??? ??? ?
?? ??? ??? ??? ?@Override
?? ??? ??? ??? ?public void onAnimationStart(Animation animation) {
?? ??? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ??? ?bottomMenu.setAlpha(255);
?? ??? ??? ??? ?}
?? ??? ??? ??? ?
?? ??? ??? ??? ?@Override
?? ??? ??? ??? ?public void onAnimationRepeat(Animation animation) {
?? ??? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?
?? ??? ??? ??? ?@Override
?? ??? ??? ??? ?public void onAnimationEnd(Animation animation) {
?? ??? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ?}
?? ??? ??? ?});
?? ??? ??? ?animation.setDuration(duration);
?? ??? ??? ?bottomMenu.startAnimation(animation);
?? ??? ?}
?? ?});
? ?}
? ?
? ?
? ?public void hideBottomMenu(View layout,final int duration){
?? ??? ? //對(duì)當(dāng)前頁(yè)面進(jìn)行截屏
?? ??? ? ?? ??? ?layout.setDrawingCacheEnabled(true); ?
?? ??? ? ?? ??? ?layout.buildDrawingCache(); ?//啟用DrawingCache并創(chuàng)建位圖 ?
?? ??? ? ?? ??? ?Bitmap screen = Bitmap.createBitmap(layout.getDrawingCache()); //創(chuàng)建一個(gè)DrawingCache的拷貝,因?yàn)镈rawingCache得到的位圖在禁用后會(huì)被回收 ?
?? ??? ? ?? ??? ?layout.setDrawingCacheEnabled(false); ?//禁用DrawingCahce否則會(huì)影響性能 ?
?? ??? ? ? ? ?? ?
?? ??? ? ?? ??? ?//將截屏進(jìn)行模糊
?? ??? ? ?? ??? ?screen = Blur.fastblur(this, screen, 10);
?? ??? ? ?? ??? ?bottomBack.setoriginalImage(screen);
?? ??? ? ?? ??? ?
?? ??? ? ?? ??? ?
?? ??? ? ??
?? ??? ? ? bottomMenu.post(new Runnable() {
?? ??? ??? ?
?? ??? ??? ?@Override
?? ??? ??? ?public void run() {
?? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ?Animation animation = new TranslateAnimation(0, 0, 0, +bottomMenu.getHeight());//這里彈出框的高度的dp需要事先寫死
?? ??? ??? ??? ?bottomBack.handleScroll(bottomBack.getOriginalImage().getHeight()-bottomMenu.getHeight(), 0);
?? ??? ??? ??? ?Animation backgroundAnimation = new TranslateAnimation(0,0,0,-bottomBack.getHeight());
?? ??? ??? ??? ?backgroundAnimation.setDuration(duration);
?? ??? ??? ??? ?bottomBack.startAnimation(backgroundAnimation);
?? ??? ??? ??? ?animation.setAnimationListener(new AnimationListener() {
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void onAnimationStart(Animation animation) {
?? ??? ??? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ??? ??? ?bottomMenu.setAlpha(255);
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void onAnimationRepeat(Animation animation) {
?? ??? ??? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void onAnimationEnd(Animation animation) {
?? ??? ??? ??? ??? ??? ?// TODO Auto-generated method stub
?? ??? ??? ??? ??? ??? ?bottomMenu.setVisibility(View.GONE);
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?});
?? ??? ??? ??? ?animation.setDuration(duration);
?? ??? ??? ??? ?bottomMenu.startAnimation(animation);
?? ??? ??? ?}
?? ??? ?});
?? ? ? }
? ?
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Android 使用gradle打包Assets目錄的案例

    Android 使用gradle打包Assets目錄的案例

    這篇文章主要介紹了Android 使用gradle打包Assets目錄的案例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2021-02-02
  • java,Android:在eclipse中的快捷鍵(經(jīng)典收藏)

    java,Android:在eclipse中的快捷鍵(經(jīng)典收藏)

    下面的快捷鍵是常用的,本人就本身喜好且常用的收拾一下,現(xiàn)在曬出來(lái)與大家分享,感興趣的朋友可以了解小哦
    2013-01-01
  • Flutter 設(shè)置全局字體的實(shí)現(xiàn)

    Flutter 設(shè)置全局字體的實(shí)現(xiàn)

    本文主要介紹了Flutter 設(shè)置全局字體的實(shí)現(xiàn),文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-02-02
  • Android仿微信/支付寶密碼輸入框

    Android仿微信/支付寶密碼輸入框

    這篇文章主要介紹了Android仿微信/支付寶密碼輸入框的相關(guān)資料,需要的朋友可以參考下
    2015-12-12
  • Android藍(lán)牙服務(wù)啟動(dòng)流程分析探索

    Android藍(lán)牙服務(wù)啟動(dòng)流程分析探索

    這篇文章主要介紹了Android藍(lán)牙服務(wù)啟動(dòng)流程,了解內(nèi)部原理是為了幫助我們做擴(kuò)展,同時(shí)也是驗(yàn)證了一個(gè)人的學(xué)習(xí)能力,如果你想讓自己的職業(yè)道路更上一層樓,這些底層的東西你是必須要會(huì)的
    2023-01-01
  • 詳解OpenGL Shader抗鋸齒的實(shí)現(xiàn)

    詳解OpenGL Shader抗鋸齒的實(shí)現(xiàn)

    普通繪制圓形形狀時(shí)可以看到圖形邊緣會(huì)有明顯鋸齒現(xiàn)象并不像真實(shí)圓形形狀一樣圓潤(rùn)邊緣平滑。本文將介紹如何通過(guò)自制函數(shù)實(shí)現(xiàn)抗鋸齒,需要的可以參考一下
    2022-02-02
  • 安卓逆向半次元app逆向分析源碼

    安卓逆向半次元app逆向分析源碼

    這篇文章主要為大家介紹了安卓逆向半次元app逆向分析的源碼示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-02-02
  • Android仿微信通話背景的高斯模糊效果

    Android仿微信通話背景的高斯模糊效果

    目前的應(yīng)用市場(chǎng)上,使用毛玻璃效果的APP隨處可見(jiàn),比如用過(guò)微信語(yǔ)音聊天的人可以發(fā)現(xiàn),語(yǔ)音聊天頁(yè)面就使用了高斯模糊效果。本文就使用Android仿寫一個(gè)這樣的效果
    2021-06-06
  • Android不同版本兼容性適配方法教程

    Android不同版本兼容性適配方法教程

    這篇文章主要介紹了Android不同版本兼容性適配方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧
    2022-11-11
  • Android剪貼板用法詳解

    Android剪貼板用法詳解

    這篇文章主要介紹了Android剪貼板用法詳解,以實(shí)例的形式對(duì)Android中剪貼板的各類傳值方法做了較為詳細(xì)的講述,需要的朋友可以參考下
    2014-10-10

最新評(píng)論