|
|
When implementing screens for the Akamu App, it may occur that you want to use a loading animation while the app is communicating with the server. A blueprint layout for this already exists. You can find it under ``res/layout/layout_dotloader.xml`` and ``res/layout/layout_load_failed.xml``.
|
|
|
|
|
|
****DotLoader Layout****
|
|
|
|
|
|
This layout file uses [this](https://github.com/bhargavms/DotLoader) library by Bhargav Mogra to display some fancy hopping dots while loading data. Include this layout file to the layout file you're working on with the following code:
|
|
|
|
|
|
````kotlin
|
|
|
...
|
|
|
<include layout="@layout/layout_dotloader"
|
|
|
android:id="@+id/layout_dotloader_my_layout"
|
|
|
android:visibility="gone"/>
|
|
|
...
|
|
|
````
|
|
|
|
|
|
The visibility is set to "gone" because otherwise we would see this layout always in the layout editor. Change the visibility of this included layout in your activity whenever you want to show a loading animation. You should set the visibility to "gone" again after the loading is done.
|
|
|
|
|
|
****Loading Failed Layout****
|
|
|
|
|
|
This layout file shows an image of the akamu elephant after loading has failed. Furthermore you can let it show the reason why the loading task has failed. Include this layout file to the layout file you're working on with the following code:
|
|
|
|
|
|
````kotlin
|
|
|
...
|
|
|
<include layout="@layout/layout_load_failed"
|
|
|
android:id="@+id/layout_load_failed_my_layout"
|
|
|
android:visibility="gone"/>
|
|
|
...
|
|
|
````
|
|
|
|
|
|
The visibility is set to "gone" because otherwise we would see this layout always in the layout editor. Change the visibility of this included layout in your activity whenever you want to indicate that a loading task has failed. |
|
|
\ No newline at end of file |