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. 额,你不觉得用包名加控件名太难看了 吗? 有没有办法像android自带的那样,去掉包名前缀呢

  2. Pingback: Payday loans

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

  4. Pingback: Skydiving NYC

  5. Pingback: What is the use of coconut oil

  6. Pingback: garcinia cambogia extract does it work

  7. Pingback: double glazing windows

  8. Pingback: pickleball paddle

  9. Pingback: hotels in burlington nc

  10. Pingback: water slide

  11. Pingback: interserver coupon

  12. Pingback: interserver promo code

  13. Pingback: must see

  14. Pingback: click here

  15. Pingback: read more

  16. Pingback: new website

  17. Pingback: useful reference

  18. Pingback: my company

  19. Pingback: a fantastic read

  20. Pingback: original site

  21. Pingback: why not try these out

  22. Pingback: look at this site

  23. Pingback: check these guys out

  24. Pingback: you can try this out

  25. Pingback: navigate to these guys

  26. Pingback: additional hints

  27. Pingback: More Bonuses

  28. Pingback: Continued

  29. Pingback: Discover More

  30. Pingback: click resources

  31. Pingback: pop over to this website

  32. Pingback: content

  33. Pingback: see post

  34. Pingback: look here

  35. Pingback: read more

  36. Pingback: best info

  37. Pingback: new website

  38. Pingback: news

  39. Pingback: how to

  40. Pingback: about

  41. Pingback: useful reference

  42. Pingback: imp source

  43. Pingback: a fantastic read

  44. Pingback: my response

  45. Pingback: i thought about this

  46. Pingback: check these guys out

  47. Pingback: view publisher site

  48. Pingback: why not find out more

  49. Pingback: their explanation

  50. Pingback: Visit Website

  51. Pingback: her latest blog

  52. Pingback: More Bonuses

  53. Pingback: check that

  54. Pingback: you could try here

  55. Pingback: Learn More

  56. Pingback: Get the facts

  57. Pingback: official statement

  58. Pingback: click here

  59. Pingback: read more

  60. Pingback: click here

  61. Pingback: click here

  62. Pingback: click here

  63. Pingback: read more

  64. Pingback: read more

  65. Pingback: read more

  66. Pingback: read more

  67. Pingback: website

  68. Pingback: click here

  69. Pingback: read more

  70. Pingback: more news

  71. Pingback: check this link right here now

  72. Pingback: official site

  73. Pingback: check these guys out

  74. Pingback: her latest blog

  75. Pingback: Clicking Here

  76. Pingback: More hints

  77. Pingback: best value

  78. Pingback: new source

  79. Pingback: best news

  80. Pingback: learn now

  81. Pingback: givehermakeup.com

  82. Pingback: click here

  83. Pingback: read more

  84. Pingback: important

  85. Pingback: find

  86. Pingback: figure out

  87. Pingback: continue reading

  88. Pingback: what to do

  89. Pingback: where to look

  90. Pingback: insight

  91. Pingback: quality article

  92. Pingback: quality article

  93. Pingback: sperry's for girls

  94. Pingback: More about the author

  95. Pingback: useful reference

  96. Pingback: i thought about this

  97. Pingback: their explanation

  98. Pingback: Homepage

  99. Pingback: a fantastic read

  100. Pingback: find this

  101. Pingback: browse this site

  102. Pingback: my response

  103. Pingback: i thought about this

  104. Pingback: why not try these out

  105. Pingback: More hints

  106. Pingback: Get the facts

  107. Pingback: official statement

  108. Pingback: try this web-site

  109. Pingback: explanation

  110. Pingback: discover this info here

  111. Pingback: minigun fallout new vegas

  112. Pingback: sperrys under $40

  113. Pingback: read more

  114. Pingback: check my blog

  115. Pingback: More about the author

  116. Pingback: click site

  117. Pingback: my review here

  118. Pingback: get redirected here

  119. Pingback: useful reference

  120. Pingback: Get More Info

  121. Pingback: see here

  122. Pingback: how to get bigger boobs

  123. Pingback: how to get bigger boobs

  124. Pingback: this website

  125. Pingback: great post to read

  126. Pingback: my company

  127. Pingback: imp source

  128. Pingback: click to read more

  129. Pingback: find more info

  130. Pingback: see it here

  131. Pingback: how to get bigger boobs

  132. Pingback: Homepage

  133. Pingback: a fantastic read

  134. Pingback: find this

  135. Pingback: Bonuses

  136. Pingback: read this article

  137. Pingback: click here now

  138. Pingback: browse this site

  139. Pingback: original site

  140. Pingback: my response

  141. Pingback: this page

  142. Pingback: navigate to this website

  143. Pingback: news

  144. Pingback: have a peek at these guys

  145. Pingback: have a peek at these guys

  146. Pingback: click here

  147. Pingback: click here

  148. Pingback: click here

  149. Pingback: click here

  150. Pingback: read more

  151. Pingback: read more

  152. Pingback: read more

  153. Pingback: read more

  154. Pingback: what is new

  155. Pingback: what is new

  156. Pingback: what is new