径向羽化 FingerTransparentView

前不久群里有人问怎么实现「类似 Instagram 径向模糊透露手指底部内容」的效果。device-2015-08-06-133045-d因为要实时用算法羽化其实挺麻烦的,效率也不见得好,于是我当即很快提供了一个思路便是通过 Ps 做一张中心透明,边缘羽化的图片,再结合 Android 自定义 View 常用的 Canvas 与 Paint 这两个类的混合模式 Xfermode,在白板上挖出一个能容纳这张羽化图片的洞,混合去除,再将羽化图片填充进去即可。

说来抽象,结果便是如右 GIF 图所示。正好那天比较闲,想得快,做得也快,一个钟头完全靠着自己就几乎完美实现了。

Maven:

dependencies {
    compile 'me.drakeet.fingertransparentview:fingertransparentview:1.0.1'
}

不过,一般人可能不会用到这个东西,之所以在这边写出来,觉得它还是挺不错的一个自定义 View 教程,开发者可以看看源码学习下也不错,主要可以学到的内容有:

  • 双指缩放 Bitmap
  • 触摸事件分发与传递
  • Android 提供的混合绘图接口 Xfermode
  • 自定义 View 的一些流程

源代码:https://github.com/drakeet/FingerTransparentView

遗留小问题:眼尖的同学可能会发现使劲看可以看得出图片边缘,这主要是 baseColor 我偷懒直接使用 Color.WHITE 衔接不完美导致的,可以通过调整这个变量获得完美衔接,或者重新 P 一张羽化图片也行。

  1. Pingback: Skydiving NYC

  2. Pingback: What is the use of coconut oil

  3. Pingback: where can i get garcinia cambogia extract

  4. Pingback: How are contributions made to the 403b account

  5. Pingback: Double glazing window

  6. Pingback: pickleball ball

  7. Pingback: hotels in burlington nc

  8. Pingback: water slide

  9. Pingback: interserver coupon

  10. Pingback: interserver coupon

  11. Pingback: Read More

  12. Pingback: click here

  13. Pingback: useful reference

  14. Pingback: my company

  15. Pingback: a fantastic read

  16. Pingback: original site

  17. Pingback: why not try these out

  18. Pingback: look at this site

  19. Pingback: check these guys out

  20. Pingback: you can try this out

  21. Pingback: navigate to these guys

  22. Pingback: additional hints

  23. Pingback: More Bonuses

  24. Pingback: Continued

  25. Pingback: Discover More

  26. Pingback: click resources

  27. Pingback: pop over to this website

  28. Pingback: content

  29. Pingback: see post

  30. Pingback: look here

  31. Pingback: read more

  32. Pingback: best info

  33. Pingback: new website

  34. Pingback: news

  35. Pingback: how to

  36. Pingback: about

  37. Pingback: useful reference

  38. Pingback: imp source

  39. Pingback: a fantastic read

  40. Pingback: my response

  41. Pingback: check these guys out

  42. Pingback: view publisher site

  43. Pingback: their explanation

  44. Pingback: More Bonuses

  45. Pingback: check that

  46. Pingback: you could check here

  47. Pingback: you could try here

  48. Pingback: Learn More

  49. Pingback: Get the facts

  50. Pingback: official statement

  51. Pingback: important source

  52. Pingback: read more

  53. Pingback: click here

  54. Pingback: read more

  55. Pingback: read more

  56. Pingback: read more

  57. Pingback: read more

  58. Pingback: click here

  59. Pingback: read more

  60. Pingback: more news

  61. Pingback: i thought about this

  62. Pingback: check these guys out

  63. Pingback: her latest blog

  64. Pingback: Clicking Here

  65. Pingback: More hints

  66. Pingback: best value

  67. Pingback: new source

  68. Pingback: best news

  69. Pingback: learn now

  70. Pingback: givehermakeup.com

  71. Pingback: read more

  72. Pingback: important

  73. Pingback: find

  74. Pingback: figure out

  75. Pingback: continue reading

  76. Pingback: what to do

  77. Pingback: where to look

  78. Pingback: where to look

  79. Pingback: insight

  80. Pingback: quality article

  81. Pingback: quality article

  82. Pingback: Sperry boots for women

  83. Pingback: More about the author

  84. Pingback: useful reference

  85. Pingback: i thought about this

  86. Pingback: their explanation

  87. Pingback: Homepage

  88. Pingback: a fantastic read

  89. Pingback: find this

  90. Pingback: browse this site

  91. Pingback: my response

  92. Pingback: i thought about this

  93. Pingback: why not try these out

  94. Pingback: More hints

  95. Pingback: you could look here

  96. Pingback: official statement

  97. Pingback: try this web-site

  98. Pingback: explanation

  99. Pingback: minigun fallout 4 ammo

  100. Pingback: sperrys khakis

  101. Pingback: read more

  102. Pingback: check my blog

  103. Pingback: More about the author

  104. Pingback: click site

  105. Pingback: my review here

  106. Pingback: get redirected here

  107. Pingback: Get More Info

  108. Pingback: see here

  109. Pingback: how to get bigger boobs naturally fast

  110. Pingback: how to get bigger boobs naturally fast

  111. Pingback: this website

  112. Pingback: great post to read

  113. Pingback: imp source

  114. Pingback: click to read more

  115. Pingback: find more info

  116. Pingback: see it here

  117. Pingback: how to get bigger boobs

  118. Pingback: Homepage

  119. Pingback: find this

  120. Pingback: Bonuses

  121. Pingback: read this article

  122. Pingback: click here now

  123. Pingback: browse this site

  124. Pingback: check here

  125. Pingback: original site

  126. Pingback: navigate to this website

  127. Pingback: news

  128. Pingback: have a peek at these guys

  129. Pingback: have a peek at these guys

  130. Pingback: click here

  131. Pingback: click here

  132. Pingback: click here

  133. Pingback: click here

  134. Pingback: read more

  135. Pingback: read more

  136. Pingback: read more

  137. Pingback: read more

  138. Pingback: what is new

  139. Pingback: what is new

  140. Pingback: what is new

  141. Pingback: what is new

  142. Pingback: buy dofollow High PR web 2.0 profile backlinks