Advertisement
akram_0090

android animated balls

Jul 18th, 2017
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 8.94 KB | None | 0 0
  1. http://casualient.com/f9t
  2.  
  3. A highly configurable library to do loading progress with animated balls
  4. Custom attributes
  5.  
  6. lib:path="triangle"
  7. The shape of the movement, available:
  8.  
  9. *  infinite
  10. *  square
  11. *  triangle
  12. *  circle
  13. *  diamond
  14. *  star
  15. lib:balls="3"
  16. Number of balls used in the animation
  17.  
  18. lib:movement_cycle_time="1500"
  19. The time which the ball takes to do a complete cicle
  20.  
  21. lib:enable_size_animation="true"
  22. Enables the size animation in the balls (by default is false)
  23.  
  24. lib:size_cycle_time="500"
  25. The time it takes to the ball to grow up and decrease the size one time
  26.  
  27. lib:ball_size="6dp"
  28. Set the balls size
  29.  
  30. lib:min_ball_size="5dp"
  31. lib:max_ball_size="12dp"
  32. To use with enable_size_animation="true", set the min and the max ball size
  33.  
  34. lib:ball_colors="@array/colors"
  35. Array of colors for the balls, if there are more balls than colors then repeat color balls
  36.  
  37. <?xml version="1.0" encoding="utf-8"?>
  38. <resources>
  39.   <color name="ball1">#FFD91C</color>
  40.   <color name="ball2">#FF4B4A</color>
  41.   <color name="ball3">#3D8EFF</color>
  42.  
  43.   <integer-array name="colors">
  44.     <item>@color/ball1</item>
  45.     <item>@color/ball2</item>
  46.     <item>@color/ball3</item>
  47.   </integer-array>
  48. </resources>
  49. Sample colors array
  50.  
  51. For Gradle
  52.  
  53. Add repository
  54.  
  55. repositories {
  56.   maven {
  57.     url "http://dl.bintray.com/glomadrian/maven"
  58.   }
  59. }
  60. Add dependency
  61.  
  62.   compile 'com.github.glomadrian:loadingballs:1.1@aar'
  63. Some Samples
  64.  
  65. Default Infinite shape
  66.  
  67. Sample
  68.  
  69. <com.github.glomadrian.loadingballs.BallView
  70.      android:layout_margin="30dp"
  71.      android:layout_width="100dp"
  72.      android:layout_height="100dp"
  73.      lib:balls="3"
  74.      lib:movement_cycle_time="1500"
  75.      lib:enable_size_animation="true"
  76.      lib:size_cycle_time="500"
  77.      lib:min_ball_size="5dp"
  78.      lib:max_ball_size="12dp"
  79.      lib:ball_colors="@array/colors"
  80.      android:layout_gravity="center"
  81.      />
  82. Infinite shape without size animation
  83.  
  84. Sample
  85.  
  86. <com.github.glomadrian.loadingballs.BallView
  87.       android:layout_margin="30dp"
  88.       android:layout_width="100dp"
  89.       android:layout_height="100dp"
  90.       lib:balls="3"
  91.       lib:movement_cycle_time="1000"
  92.       lib:enable_size_animation="false"
  93.       lib:ball_colors="@array/colors"
  94.       android:layout_gravity="center"
  95.       />
  96. Infinite shape with 5 balls
  97.  
  98. Sample
  99.  
  100. <com.github.glomadrian.loadingballs.BallView
  101.     android:layout_margin="30dp"
  102.     android:layout_width="100dp"
  103.     android:layout_height="100dp"
  104.     lib:balls="5"
  105.     lib:movement_cycle_time="1500"
  106.     lib:enable_size_animation="true"
  107.     lib:size_cycle_time="500"
  108.     lib:min_ball_size="5dp"
  109.     lib:max_ball_size="12dp"
  110.     lib:ball_colors="@array/colors"
  111.     android:layout_gravity="center"
  112.     />
  113. Triangle shape with 3 balls and size animation
  114.  
  115. Sample
  116.  
  117. <com.github.glomadrian.loadingballs.BallView
  118.        android:layout_margin="30dp"
  119.        android:layout_width="100dp"
  120.        android:layout_height="100dp"
  121.        lib:balls="3"
  122.        lib:movement_cycle_time="1500"
  123.        lib:enable_size_animation="true"
  124.        lib:size_cycle_time="500"
  125.        lib:min_ball_size="5dp"
  126.        lib:max_ball_size="12dp"
  127.        lib:ball_colors="@array/colors"
  128.        lib:path="triangle"
  129.        android:layout_gravity="center"
  130.        />
  131. Triangle shape with 2 balls
  132.  
  133. Sample
  134.  
  135. <com.github.glomadrian.loadingballs.BallView
  136.         android:layout_margin="30dp"
  137.         android:layout_width="100dp"
  138.         android:layout_height="100dp"
  139.         lib:balls="2"
  140.         lib:movement_cycle_time="800"
  141.         lib:enable_size_animation="false"
  142.         lib:ball_colors="@array/colors"
  143.         lib:path="triangle"
  144.         android:layout_gravity="center"
  145.         />
  146. Square shape with 3 balls
  147.  
  148. Sample
  149.  
  150. <com.github.glomadrian.loadingballs.BallView
  151.     android:layout_margin="30dp"
  152.     android:layout_width="100dp"
  153.     android:layout_height="100dp"
  154.     lib:balls="3"
  155.     lib:movement_cycle_time="800"
  156.     lib:enable_size_animation="false"
  157.     lib:ball_colors="@array/colors"
  158.     lib:path="square"
  159.     android:layout_gravity="center"
  160.     />
  161. Square shape with 5 balls and size animation
  162.  
  163. Sample
  164.  
  165. <com.github.glomadrian.loadingballs.BallView
  166.     android:layout_margin="30dp"
  167.     android:layout_width="100dp"
  168.     android:layout_height="100dp"
  169.     lib:balls="5"
  170.     lib:movement_cycle_time="1200"
  171.     lib:enable_size_animation="true"
  172.     lib:size_cycle_time="500"
  173.     lib:min_ball_size="5dp"
  174.     lib:max_ball_size="12dp"
  175.     lib:ball_colors="@array/colors"
  176.     lib:path="square"
  177.     android:layout_gravity="center"
  178.     />
  179. Circle shape with 3 balls and size animation
  180.  
  181. Sample
  182.  
  183. <com.github.glomadrian.loadingballs.BallView
  184.     android:layout_margin="30dp"
  185.     android:layout_width="100dp"
  186.     android:layout_height="100dp"
  187.     lib:balls="3"
  188.     lib:movement_cycle_time="1200"
  189.     lib:enable_size_animation="true"
  190.     lib:size_cycle_time="1500"
  191.     lib:min_ball_size="5dp"
  192.     lib:max_ball_size="12dp"
  193.     lib:ball_colors="@array/colors"
  194.     lib:path="circle"
  195.     android:layout_gravity="center"
  196.     />
  197. Circle shape with 2 balls without size animation
  198.  
  199. Sample
  200.  
  201. <com.github.glomadrian.loadingballs.BallView
  202.     android:layout_margin="30dp"
  203.     android:layout_width="100dp"
  204.     android:layout_height="100dp"
  205.     lib:balls="2"
  206.     lib:movement_cycle_time="700"
  207.     lib:enable_size_animation="false"
  208.     lib:ball_colors="@array/colors"
  209.     lib:path="circle"
  210.     android:layout_gravity="center"
  211.     />
  212. Star shape with 10 balls without size animation
  213.  
  214. Sample
  215.  
  216. <com.github.glomadrian.loadingballs.BallView
  217.     android:layout_margin="30dp"
  218.     android:layout_width="100dp"
  219.     android:layout_height="100dp"
  220.     lib:balls="10"
  221.     lib:movement_cycle_time="2500"
  222.     lib:enable_size_animation="false"
  223.     lib:ball_colors="@array/colors"
  224.     lib:path="star"
  225.     lib:ball_size="5dp"
  226.     android:layout_gravity="center"
  227.     />
  228. Star shape with 5 balls and size animation
  229.  
  230. Sample
  231.  
  232. <com.github.glomadrian.loadingballs.BallView
  233.          android:layout_margin="30dp"
  234.          android:layout_width="100dp"
  235.          android:layout_height="100dp"
  236.          lib:balls="5"
  237.          lib:movement_cycle_time="2500"
  238.          lib:ball_colors="@array/colors"
  239.          lib:path="star"
  240.          lib:ball_size="5dp"
  241.          lib:enable_size_animation="true"
  242.          lib:size_cycle_time="800"
  243.          lib:min_ball_size="5dp"
  244.          lib:max_ball_size="8dp"
  245.          android:layout_gravity="center"
  246.          />
  247. Star shape with 3 balls and size animation
  248.  
  249. Sample
  250.  
  251. <com.github.glomadrian.loadingballs.BallView
  252.     android:layout_margin="30dp"
  253.     android:layout_width="100dp"
  254.     android:layout_height="100dp"
  255.     lib:balls="3"
  256.     lib:movement_cycle_time="2500"
  257.     lib:ball_colors="@array/colors"
  258.     lib:path="star"
  259.     lib:ball_size="5dp"
  260.     lib:enable_size_animation="true"
  261.     lib:size_cycle_time="800"
  262.     lib:min_ball_size="5dp"
  263.     lib:max_ball_size="8dp"
  264.     android:layout_gravity="center"
  265.     />
  266. Diamond shape with 5 balls without size animation
  267.  
  268. Sample
  269.  
  270. <com.github.glomadrian.loadingballs.BallView
  271.     android:layout_margin="30dp"
  272.     android:layout_width="100dp"
  273.     android:layout_height="100dp"
  274.     lib:balls="5"
  275.     lib:movement_cycle_time="2500"
  276.     lib:ball_colors="@array/colors"
  277.     lib:path="diamond"
  278.     lib:ball_size="6dp"
  279.     android:layout_gravity="center"
  280.     />
  281. Diamond shape with 4 balls and size animation
  282.  
  283. Sample
  284.  
  285. <com.github.glomadrian.loadingballs.BallView
  286.          android:layout_margin="30dp"
  287.          android:layout_width="100dp"
  288.          android:layout_height="100dp"
  289.          lib:balls="4"
  290.          lib:movement_cycle_time="2500"
  291.          lib:ball_colors="@array/colors"
  292.          lib:path="diamond"
  293.          lib:ball_size="5dp"
  294.          lib:enable_size_animation="true"
  295.          lib:size_cycle_time="800"
  296.          lib:min_ball_size="5dp"
  297.          lib:max_ball_size="8dp"
  298.          android:layout_gravity="center"
  299.          />
  300. Diamond shape with 10 balls without size animation
  301.  
  302. Sample
  303.  
  304. <com.github.glomadrian.loadingballs.BallView
  305.     android:layout_margin="30dp"
  306.     android:layout_width="100dp"
  307.     android:layout_height="100dp"
  308.     lib:balls="10"
  309.     lib:movement_cycle_time="2500"
  310.     lib:ball_colors="@array/colors"
  311.     lib:path="diamond"
  312.     lib:ball_size="4dp"
  313.     android:layout_gravity="center"
  314.     />
  315. Developed By
  316.  
  317. Adrián García Lomas - glomadrian@gmail.com
  318.  
  319. Twitter
  320. LinkedIn
  321. License
  322.  
  323. Copyright 2015 Adrián García Lomas
  324. Copyright 2015 Adrián García Lomas
  325.  
  326. Licensed under the Apache License, Version 2.0 (the "License");
  327. you may not use this file except in compliance with the License.
  328. You may obtain a copy of the License at
  329.  
  330.    http://www.apache.org/licenses/LICENSE-2.0
  331.  
  332. Unless required by applicable law or agreed to in writing, software
  333. distributed under the License is distributed on an "AS IS" BASIS,
  334. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  335. See the License for the specific language governing permissions and
  336. limitations under the License.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement