AndroidUIView

前不久开始自学 Swift 并且开始开发 iOS App,发现 iOS 的 UIButton 有个特性特别喜欢,就是你只需要设置按钮的背景图片即可自动带有按下去按钮变暗的效果,而 Android 如果要做到一样的效果,通常都需要写一个 xml 文件,写 selector,而且设计师也要配合着做两种状态的图,即正常状态的图 + 按钮被按下去的状态图。 所以觉得 iOS 的这个 UIButton 这点非常实在(=。=),便简单仿造着做了个 AndroidUIView,并且提供了 XML 自定义接口,可以设置按下去蒙版的颜色、透明度、形状,还有圆角: s1 s2

(分别是正常状态图和按下去之后的状态图)

https://github.com/drakeet/AndroidUIView

使用方法:

1. Gradle

dependencies {
    compile 'me.drakeet.library:androiduiview:1.0.0'
}

2. 在布局 XML 文件中根节点添加命名空间:

xmlns:drakeet="http://schemas.android.com/apk/res-auto"

3. 之后就可以愉快地使用了,如下(也可以参考截图):

<me.drakeet.library.UIButton
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_margin="16dp"
    drakeet:alpha_pressed="80"
    drakeet:color_pressed="#660303ff"
    android:background="@mipmap/ic_launcher"/>

<me.drakeet.library.UIButton
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_margin="16dp"
    drakeet:shape_type="round"
    android:background="@mipmap/avatar"/>
    
<me.drakeet.library.UIImageView
    android:layout_width="64dp"
    android:layout_height="64dp"
    android:layout_margin="16dp"
    drakeet:shape_type="round"
    android:src="@mipmap/avatar2"/>

自定义属性:

  • drakeet:alpha_pressed [integer 默认:48 0-255] –> Alpha of the cover color when pressed
  • drakeet:color_pressed [color 默认:#9c000000] –> Color of the cover when pressed
  • drakeet:shape_type [enum (rectangle, round) 默认:rectangle] –> Rectangle or round of cover shape
  • drakeet:radius [dimension 默认:2dp] –> Add a radius to the cover

Demo apk 下载

  1. Pingback: what is new

  2. Pingback: what is new

  3. Pingback: what is new

  4. Pingback: read more

  5. Pingback: read more

  6. Pingback: read more

  7. Pingback: read more

  8. Pingback: click here

  9. Pingback: click here

  10. Pingback: click here

  11. Pingback: click here

  12. Pingback: have a peek at these guys

  13. Pingback: have a peek at these guys

  14. Pingback: news

  15. Pingback: navigate to this website

  16. Pingback: this page

  17. Pingback: my response

  18. Pingback: original site

  19. Pingback: browse this site

  20. Pingback: click here now

  21. Pingback: read this article

  22. Pingback: Bonuses

  23. Pingback: find this

  24. Pingback: a fantastic read

  25. Pingback: Homepage

  26. Pingback: how to get bigger boobs

  27. Pingback: see it here

  28. Pingback: find more info

  29. Pingback: click to read more

  30. Pingback: imp source

  31. Pingback: my company

  32. Pingback: great post to read

  33. Pingback: this website

  34. Pingback: how to get bigger boobs

  35. Pingback: how to get bigger boobs

  36. Pingback: see here

  37. Pingback: Get More Info

  38. Pingback: useful reference

  39. Pingback: get redirected here

  40. Pingback: my review here

  41. Pingback: click site

  42. Pingback: More about the author

  43. Pingback: check my blog

  44. Pingback: read more

  45. Pingback: sperrys under $40

  46. Pingback: minigun fallout new vegas

  47. Pingback: discover this info here

  48. Pingback: explanation

  49. Pingback: try this web-site

  50. Pingback: official statement

  51. Pingback: Get the facts

  52. Pingback: More hints

  53. Pingback: why not try these out

  54. Pingback: i thought about this

  55. Pingback: my response

  56. Pingback: browse this site

  57. Pingback: find this

  58. Pingback: a fantastic read

  59. Pingback: Homepage

  60. Pingback: their explanation

  61. Pingback: i thought about this

  62. Pingback: useful reference

  63. Pingback: More about the author

  64. Pingback: sperry's for girls

  65. Pingback: quality article

  66. Pingback: quality article

  67. Pingback: insight

  68. Pingback: where to look

  69. Pingback: what to do

  70. Pingback: continue reading

  71. Pingback: figure out

  72. Pingback: find

  73. Pingback: important

  74. Pingback: read more

  75. Pingback: click here

  76. Pingback: givehermakeup.com

  77. Pingback: learn now

  78. Pingback: best news

  79. Pingback: new source

  80. Pingback: best value

  81. Pingback: More hints

  82. Pingback: Clicking Here

  83. Pingback: her latest blog

  84. Pingback: check these guys out

  85. Pingback: official site

  86. Pingback: check this link right here now

  87. Pingback: more news

  88. Pingback: read more

  89. Pingback: click here

  90. Pingback: website

  91. Pingback: read more

  92. Pingback: read more

  93. Pingback: read more

  94. Pingback: read more

  95. Pingback: click here

  96. Pingback: click here

  97. Pingback: click here

  98. Pingback: read more

  99. Pingback: click here

  100. Pingback: official statement

  101. Pingback: Get the facts

  102. Pingback: Learn More

  103. Pingback: you could try here

  104. Pingback: check that

  105. Pingback: More Bonuses

  106. Pingback: her latest blog

  107. Pingback: Visit Website

  108. Pingback: their explanation

  109. Pingback: why not find out more

  110. Pingback: view publisher site

  111. Pingback: check these guys out

  112. Pingback: i thought about this

  113. Pingback: my response

  114. Pingback: a fantastic read

  115. Pingback: imp source

  116. Pingback: useful reference

  117. Pingback: about

  118. Pingback: how to

  119. Pingback: news

  120. Pingback: new website

  121. Pingback: best info

  122. Pingback: read more

  123. Pingback: look here

  124. Pingback: see post

  125. Pingback: content

  126. Pingback: pop over to this website

  127. Pingback: click resources

  128. Pingback: Discover More

  129. Pingback: Continued

  130. Pingback: More Bonuses

  131. Pingback: additional hints

  132. Pingback: navigate to these guys

  133. Pingback: you can try this out

  134. Pingback: check these guys out

  135. Pingback: look at this site

  136. Pingback: why not try these out

  137. Pingback: original site

  138. Pingback: a fantastic read

  139. Pingback: my company

  140. Pingback: useful reference

  141. Pingback: new website

  142. Pingback: read more

  143. Pingback: click here

  144. Pingback: must see

  145. Pingback: interserver promo code

  146. Pingback: interserver coupon

  147. Pingback: water slide

  148. Pingback: hotels in burlington nc

  149. Pingback: pickleball paddle

  150. Pingback: double glazing windows

  151. Pingback: garcinia cambogia extract does it work

  152. Pingback: What is the use of coconut oil

  153. Pingback: Skydiving NYC

  154. 为什么 compile ‘me.drakeet.library:androiduiview:1.0.0’ 一句这个就能自动使用你这个库了呢,我还没下载jar包呢。。神奇

  155. Pingback: Payday loans

  156. 额,你不觉得用包名加控件名太难看了 吗? 有没有办法像android自带的那样,去掉包名前缀呢