├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── encodings.xml ├── gradle.xml ├── inspectionProfiles │ ├── Project_Default.xml │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── BlurViewProject.iml ├── README.md ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── libs │ └── colorpicker.aar ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── licheedev │ │ └── blurviewproject │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── licheedev │ │ └── blurviewproject │ │ ├── BaseTestActivity.java │ │ ├── LiveBlurActivity.java │ │ ├── MainActivity.java │ │ ├── StaticBlurActivity.java │ │ ├── fragment │ │ ├── ImageFragment.java │ │ ├── ListFragment.java │ │ └── ScrollFragment.java │ │ └── listener │ │ └── ToBlurListener.java │ └── res │ ├── drawable │ ├── img_dog1.jpg │ ├── img_dog2.jpg │ ├── img_dog3.jpg │ ├── img_doge.png │ └── img_isla.png │ ├── layout │ ├── activity_live_blur.xml │ ├── activity_main.xml │ ├── activity_static_blur.xml │ ├── fragment_image.xml │ ├── fragment_list.xml │ ├── fragment_scroll.xml │ ├── layout_control.xml │ └── list_item.xml │ ├── menu │ ├── menu_base_test.xml │ ├── menu_live_blur.xml │ ├── menu_main.xml │ └── menu_static_blur.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── values-w820dp │ └── dimens.xml │ └── values │ ├── colors.xml │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── blurview ├── .gitignore ├── blurview.iml ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── licheedev │ │ └── blurview │ │ └── ApplicationTest.java │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── licheedev │ │ └── blurview │ │ ├── BlurView.java │ │ └── PartBlurView.java │ └── res │ └── values │ ├── blurview_attr.xml │ └── strings.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── screenshot └── ss.gif └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | *.iml 9 | /*/*.iml -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | Blur View Project -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 10 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /BlurViewProject.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BlurViewDemo 2 | 实现高斯模糊控件 3 | 4 | ![截图](./screenshot/ss.gif) -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 22 5 | buildToolsVersion "22.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.licheedev.blurviewproject" 9 | minSdkVersion 15 10 | targetSdkVersion 22 11 | versionCode 1 12 | versionName "1.0" 13 | renderscriptTargetApi 18 14 | renderscriptSupportModeEnabled true 15 | } 16 | buildTypes { 17 | release { 18 | minifyEnabled false 19 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 20 | } 21 | } 22 | } 23 | 24 | repositories { 25 | flatDir { 26 | dirs 'libs' 27 | } 28 | } 29 | 30 | dependencies { 31 | compile fileTree(dir: 'libs', include: ['*.jar']) 32 | compile 'com.android.support:appcompat-v7:22.2.0' 33 | compile('com.rengwuxian.materialedittext:library:2.0.3') { 34 | transitive = true; 35 | } 36 | compile(name: 'colorpicker', ext: 'aar') 37 | compile project(':blurview') 38 | } 39 | -------------------------------------------------------------------------------- /app/libs/colorpicker.aar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/licheedev/BlurViewDemo/8c43deb414f2011481c31f6f9aef7286591560dd/app/libs/colorpicker.aar -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\DevTools\Android\sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/licheedev/blurviewproject/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 22 | 23 | 26 | 27 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/BaseTestActivity.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject; 2 | 3 | import android.content.DialogInterface; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | import android.widget.Button; 8 | import android.widget.SeekBar; 9 | import android.widget.TextView; 10 | import android.widget.Toast; 11 | 12 | import com.flask.colorpicker.ColorPickerView; 13 | import com.flask.colorpicker.OnColorSelectedListener; 14 | import com.flask.colorpicker.builder.ColorPickerClickListener; 15 | import com.flask.colorpicker.builder.ColorPickerDialogBuilder; 16 | 17 | public abstract class BaseTestActivity extends AppCompatActivity implements View.OnClickListener { 18 | 19 | private TextView mTvBlurRadius; 20 | private SeekBar mSbBlurRadius; 21 | private TextView mTvDownSample; 22 | private SeekBar mSbDownSample; 23 | private View mColorView; 24 | private Button mBtnColor; 25 | 26 | protected int mBlurRadius = 0; 27 | protected int mDownSample = 1; 28 | protected int mColor; 29 | 30 | @Override 31 | protected void onCreate(Bundle savedInstanceState) { 32 | super.onCreate(savedInstanceState); 33 | } 34 | 35 | protected void initControl() { 36 | // 设置模糊半径 37 | mTvBlurRadius = (TextView) findViewById(R.id.tvBlurRadius); 38 | mSbBlurRadius = (SeekBar) findViewById(R.id.sbBlurRadius); 39 | mSbBlurRadius.setMax(24); 40 | mSbBlurRadius.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 41 | @Override 42 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 43 | setBlurRadiusText(progress); 44 | updateBlurView(mBlurRadius, mDownSample, mColor); 45 | } 46 | 47 | @Override 48 | public void onStartTrackingTouch(SeekBar seekBar) { 49 | 50 | } 51 | 52 | @Override 53 | public void onStopTrackingTouch(SeekBar seekBar) { 54 | 55 | } 56 | }); 57 | mSbBlurRadius.setProgress(0); 58 | // 设置缩小样本因数 59 | mTvDownSample = (TextView) findViewById(R.id.tvDownSample); 60 | mSbDownSample = (SeekBar) findViewById(R.id.sbDownSample); 61 | mSbDownSample.setMax(64 - 1); 62 | mSbDownSample.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 63 | @Override 64 | public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { 65 | setDownSampleText(progress); 66 | updateBlurView(mBlurRadius, mDownSample, mColor); 67 | } 68 | 69 | @Override 70 | public void onStartTrackingTouch(SeekBar seekBar) { 71 | 72 | } 73 | 74 | @Override 75 | public void onStopTrackingTouch(SeekBar seekBar) { 76 | 77 | } 78 | }); 79 | mSbDownSample.setProgress(0); 80 | // 设置颜色 81 | mColorView = findViewById(R.id.colorView); 82 | mBtnColor = (Button) findViewById(R.id.btnColor); 83 | mBtnColor.setOnClickListener(this); 84 | setColorText(getResources().getColor(R.color.green_a20)); 85 | } 86 | 87 | 88 | @Override 89 | public void onClick(View v) { 90 | switch (v.getId()) { 91 | case R.id.btnColor: 92 | selectColor(); 93 | break; 94 | 95 | } 96 | } 97 | 98 | private void selectColor() { 99 | ColorPickerDialogBuilder 100 | .with(this) 101 | .setTitle("选择颜色") 102 | .initialColor(mColor) 103 | .wheelType(ColorPickerView.WHEEL_TYPE.FLOWER) 104 | .density(12) 105 | .setOnColorSelectedListener(new OnColorSelectedListener() { 106 | @Override 107 | public void onColorSelected(int selectedColor) { 108 | Toast.makeText(getApplicationContext(), 109 | "已选择颜色: #" + Integer.toHexString(selectedColor), Toast.LENGTH_SHORT) 110 | .show(); 111 | } 112 | }) 113 | .setPositiveButton("确定", new ColorPickerClickListener() { 114 | @Override 115 | public void onClick(DialogInterface dialog, int selectedColor, 116 | Integer[] allColors) { 117 | setColorText(selectedColor); 118 | updateBlurView(mBlurRadius, mDownSample, mColor); 119 | } 120 | }) 121 | .setNegativeButton("取消", new DialogInterface.OnClickListener() { 122 | @Override 123 | public void onClick(DialogInterface dialog, int which) { 124 | } 125 | }) 126 | .build() 127 | .show(); 128 | } 129 | 130 | 131 | protected void setBlurRadiusText(int blurRadius) { 132 | mBlurRadius = blurRadius; 133 | mTvBlurRadius.setText("模糊半径:" + mBlurRadius); 134 | } 135 | 136 | protected void setDownSampleText(int downSample) { 137 | mDownSample = downSample + 1; 138 | mTvDownSample.setText("样本因数:" + mDownSample); 139 | } 140 | 141 | protected void setColorText(int color) { 142 | mColor = color; 143 | mBtnColor.setText("颜色:#" + Integer.toHexString(color)); 144 | mColorView.setBackgroundColor(mColor); 145 | } 146 | 147 | /** 148 | * 更新模糊 149 | * 150 | * @param blurRadius 151 | * @param downSample 152 | * @param color 153 | */ 154 | protected abstract void updateBlurView(int blurRadius, int downSample, int color); 155 | 156 | protected void updateBlurView() { 157 | updateBlurView(mBlurRadius, mDownSample, mColor); 158 | } 159 | 160 | } 161 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/LiveBlurActivity.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject; 2 | 3 | import android.os.Bundle; 4 | import android.support.v4.app.Fragment; 5 | import android.support.v4.app.FragmentManager; 6 | import android.support.v4.app.FragmentStatePagerAdapter; 7 | import android.support.v4.view.ViewPager; 8 | import android.widget.FrameLayout; 9 | 10 | import com.licheedev.blurview.PartBlurView; 11 | import com.licheedev.blurviewproject.fragment.ImageFragment; 12 | import com.licheedev.blurviewproject.fragment.ListFragment; 13 | import com.licheedev.blurviewproject.fragment.ScrollFragment; 14 | import com.licheedev.blurviewproject.listener.ToBlurListener; 15 | 16 | public class LiveBlurActivity extends BaseTestActivity implements ToBlurListener { 17 | 18 | private ViewPager mViewPager; 19 | private PartBlurView mBlurView1; 20 | private PartBlurView mBlurView2; 21 | private FrameLayout mContainer; 22 | 23 | @Override 24 | protected void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.activity_live_blur); 27 | initControl(); 28 | initViews(); 29 | 30 | } 31 | 32 | private void initViews() { 33 | mContainer = (FrameLayout) findViewById(R.id.container); 34 | mViewPager = (ViewPager) findViewById(R.id.viewPager); 35 | mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { 36 | @Override 37 | public void onPageScrolled(int position, float positionOffset, 38 | int positionOffsetPixels) { 39 | toBlur(); 40 | } 41 | 42 | @Override 43 | public void onPageSelected(int position) { 44 | 45 | } 46 | 47 | @Override 48 | public void onPageScrollStateChanged(int state) { 49 | 50 | } 51 | }); 52 | mViewPager.setAdapter(new MyAdapter(getSupportFragmentManager())); 53 | mBlurView1 = (PartBlurView) findViewById(R.id.blurView1); 54 | mBlurView1.setToBlurView(mContainer); 55 | mBlurView2 = (PartBlurView) findViewById(R.id.blurView2); 56 | mBlurView2.setToBlurView(mContainer); 57 | mViewPager.post(new Runnable() { 58 | @Override 59 | public void run() { 60 | mBlurView1.blur(); 61 | updateBlurView(); 62 | } 63 | }); 64 | } 65 | 66 | @Override 67 | protected void updateBlurView(int blurRadius, int downSample, int color) { 68 | mBlurView2.blur(blurRadius, downSample, color); 69 | } 70 | 71 | private class MyAdapter extends FragmentStatePagerAdapter { 72 | 73 | public MyAdapter(FragmentManager fm) { 74 | super(fm); 75 | } 76 | 77 | @Override 78 | public Fragment getItem(int position) { 79 | switch (position) { 80 | case 0: 81 | return ImageFragment.getInstance(R.drawable.img_dog1); 82 | case 1: 83 | return ImageFragment.getInstance(R.drawable.img_dog2); 84 | case 2: 85 | return ImageFragment.getInstance(R.drawable.img_dog3); 86 | case 3: 87 | return new ListFragment(); 88 | case 4: 89 | return new ScrollFragment(); 90 | default: 91 | return null; 92 | } 93 | } 94 | 95 | @Override 96 | public int getCount() { 97 | return 5; 98 | } 99 | } 100 | 101 | 102 | @Override 103 | public void toBlur() { 104 | mBlurView1.blur(); 105 | mBlurView2.blur(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject; 2 | 3 | import android.content.Intent; 4 | import android.os.Bundle; 5 | import android.support.v7.app.AppCompatActivity; 6 | import android.view.View; 7 | 8 | public class MainActivity extends AppCompatActivity implements View.OnClickListener { 9 | 10 | @Override 11 | protected void onCreate(Bundle savedInstanceState) { 12 | super.onCreate(savedInstanceState); 13 | setContentView(R.layout.activity_main); 14 | findViewById(R.id.btn1).setOnClickListener(this); 15 | findViewById(R.id.btn2).setOnClickListener(this); 16 | } 17 | 18 | @Override 19 | public void onClick(View v) { 20 | switch (v.getId()) { 21 | case R.id.btn1: 22 | startActivity(new Intent(this, StaticBlurActivity.class)); 23 | break; 24 | case R.id.btn2: 25 | startActivity(new Intent(this, LiveBlurActivity.class)); 26 | break; 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/StaticBlurActivity.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject; 2 | 3 | import android.os.Bundle; 4 | import android.widget.ImageView; 5 | 6 | import com.licheedev.blurview.BlurView; 7 | 8 | public class StaticBlurActivity extends BaseTestActivity { 9 | 10 | private ImageView mIvSrc; 11 | private BlurView mBlurView; 12 | 13 | @Override 14 | protected void onCreate(Bundle savedInstanceState) { 15 | super.onCreate(savedInstanceState); 16 | setContentView(R.layout.activity_static_blur); 17 | initControl(); 18 | initViews(); 19 | } 20 | 21 | private void initViews() { 22 | mIvSrc = (ImageView) findViewById(R.id.ivSrc); 23 | mBlurView = (BlurView) findViewById(R.id.blurView); 24 | mBlurView.setToBlurView(mIvSrc); // 并联需要模糊的视图 25 | mIvSrc.post(new Runnable() { 26 | @Override 27 | public void run() { 28 | // 初始化完毕,更新模糊视图状态 29 | updateBlurView(); 30 | } 31 | }); 32 | } 33 | 34 | @Override 35 | protected void updateBlurView(int blurRadius, int downSample, int color) { 36 | mBlurView.blur(blurRadius, downSample, color); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/fragment/ImageFragment.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject.fragment; 2 | 3 | import android.os.Bundle; 4 | import android.support.annotation.Nullable; 5 | import android.support.v4.app.Fragment; 6 | import android.view.LayoutInflater; 7 | import android.view.View; 8 | import android.view.ViewGroup; 9 | import android.widget.ImageView; 10 | 11 | import com.licheedev.blurviewproject.R; 12 | 13 | /** 14 | * Created by John on 2015/7/19. 15 | */ 16 | public class ImageFragment extends Fragment { 17 | 18 | 19 | public ImageFragment() { 20 | } 21 | 22 | public static ImageFragment getInstance(int resId) { 23 | ImageFragment fragment = new ImageFragment(); 24 | Bundle args = new Bundle(); 25 | args.putInt("resid", resId); 26 | fragment.setArguments(args); 27 | return fragment; 28 | } 29 | 30 | @Nullable 31 | @Override 32 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 33 | Bundle savedInstanceState) { 34 | ImageView imageView = (ImageView) inflater.inflate(R.layout.fragment_image, container, false); 35 | int res = getArguments().getInt("resid"); 36 | imageView.setImageResource(res); 37 | return imageView; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/fragment/ListFragment.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject.fragment; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.view.LayoutInflater; 8 | import android.view.View; 9 | import android.view.ViewGroup; 10 | import android.widget.AbsListView; 11 | import android.widget.BaseAdapter; 12 | import android.widget.ImageView; 13 | import android.widget.ListView; 14 | import android.widget.TextView; 15 | 16 | import com.licheedev.blurviewproject.R; 17 | import com.licheedev.blurviewproject.listener.ToBlurListener; 18 | 19 | /** 20 | * Created by John on 2015/7/19. 21 | */ 22 | public class ListFragment extends Fragment { 23 | 24 | private ToBlurListener mListener; 25 | 26 | @Override 27 | public void onAttach(Activity activity) { 28 | super.onAttach(activity); 29 | mListener = (ToBlurListener) activity; 30 | } 31 | 32 | @Nullable 33 | @Override 34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 35 | Bundle savedInstanceState) { 36 | ListView listView = (ListView) inflater.inflate(R.layout.fragment_list, container, false); 37 | listView.setOnScrollListener(new AbsListView.OnScrollListener() { 38 | @Override 39 | public void onScrollStateChanged(AbsListView view, int scrollState) { 40 | 41 | } 42 | 43 | @Override 44 | public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, 45 | int totalItemCount) { 46 | mListener.toBlur(); 47 | } 48 | }); 49 | listView.setAdapter(new MyAdapter()); 50 | return listView; 51 | } 52 | 53 | 54 | private static class MyAdapter extends BaseAdapter { 55 | 56 | @Override 57 | public int getCount() { 58 | return 100; 59 | } 60 | 61 | @Override 62 | public Object getItem(int position) { 63 | return null; 64 | } 65 | 66 | @Override 67 | public long getItemId(int position) { 68 | return position + 1; 69 | } 70 | 71 | @Override 72 | public View getView(int position, View convertView, ViewGroup parent) { 73 | ViewHolder holder; 74 | if (convertView == null) { 75 | convertView = LayoutInflater.from(parent.getContext()) 76 | .inflate(R.layout.list_item, parent, false); 77 | holder = new ViewHolder(convertView); 78 | convertView.setTag(holder); 79 | } else { 80 | holder = (ViewHolder) convertView.getTag(); 81 | } 82 | holder.textView.setText("这是doge " + getItemId(position)); 83 | return convertView; 84 | } 85 | } 86 | 87 | private static class ViewHolder { 88 | 89 | ImageView imageView; 90 | TextView textView; 91 | 92 | public ViewHolder(View view) { 93 | imageView = (ImageView) view.findViewById(R.id.imageView); 94 | textView = (TextView) view.findViewById(R.id.textView); 95 | } 96 | } 97 | 98 | 99 | } 100 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/fragment/ScrollFragment.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject.fragment; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.support.annotation.Nullable; 6 | import android.support.v4.app.Fragment; 7 | import android.view.DragEvent; 8 | import android.view.LayoutInflater; 9 | import android.view.View; 10 | import android.view.ViewGroup; 11 | import android.widget.ScrollView; 12 | 13 | import com.licheedev.blurviewproject.R; 14 | import com.licheedev.blurviewproject.listener.ToBlurListener; 15 | 16 | /** 17 | * Created by John on 2015/7/19. 18 | */ 19 | public class ScrollFragment extends Fragment { 20 | 21 | private ToBlurListener mListener; 22 | 23 | @Override 24 | public void onAttach(Activity activity) { 25 | super.onAttach(activity); 26 | mListener = (ToBlurListener) activity; 27 | } 28 | 29 | @Nullable 30 | @Override 31 | public View onCreateView(LayoutInflater inflater, ViewGroup container, 32 | Bundle savedInstanceState) { 33 | 34 | View view = inflater.inflate(R.layout.fragment_scroll, container, false); 35 | ScrollView scrollView = (ScrollView) view.findViewById(R.id.scrollView); 36 | scrollView.setOnDragListener(new View.OnDragListener() { 37 | @Override 38 | public boolean onDrag(View v, DragEvent event) { 39 | mListener.toBlur(); 40 | return false; 41 | } 42 | }); 43 | 44 | return view; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /app/src/main/java/com/licheedev/blurviewproject/listener/ToBlurListener.java: -------------------------------------------------------------------------------- 1 | package com.licheedev.blurviewproject.listener; 2 | 3 | /** 4 | * Created by John on 2015/7/19. 5 | */ 6 | public interface ToBlurListener { 7 | void toBlur(); 8 | } 9 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/img_dog1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/licheedev/BlurViewDemo/8c43deb414f2011481c31f6f9aef7286591560dd/app/src/main/res/drawable/img_dog1.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/img_dog2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/licheedev/BlurViewDemo/8c43deb414f2011481c31f6f9aef7286591560dd/app/src/main/res/drawable/img_dog2.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/img_dog3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/licheedev/BlurViewDemo/8c43deb414f2011481c31f6f9aef7286591560dd/app/src/main/res/drawable/img_dog3.jpg -------------------------------------------------------------------------------- /app/src/main/res/drawable/img_doge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/licheedev/BlurViewDemo/8c43deb414f2011481c31f6f9aef7286591560dd/app/src/main/res/drawable/img_doge.png -------------------------------------------------------------------------------- /app/src/main/res/drawable/img_isla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/licheedev/BlurViewDemo/8c43deb414f2011481c31f6f9aef7286591560dd/app/src/main/res/drawable/img_isla.png -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_live_blur.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 14 | 15 | 19 | 23 | 24 | 25 | 26 | 37 | 38 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 |