Last active
April 26, 2019 10:39
-
-
Save wislon/a013a189dc245da2ffef to your computer and use it in GitHub Desktop.
Transparent WebView Load Animated Gif (Xamarin Android)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
> | |
<WebView | |
android:id="@+id/webLoadingIcon" | |
android:layout_width="44dp" | |
android:layout_height="44dp" | |
android:layout_gravity="center_horizontal|center_vertical" | |
android:layout_marginTop="120dp" | |
android:background="#00000000" | |
/> | |
</LinearLayout> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void LoadAnimatedGif() | |
{ | |
webLoadingIcon = currentView.FindViewById<WebView>(Resource.Id.webLoadingIcon); | |
// expects to find the 'loading_icon_small.gif' file in the 'root' of the assets folder, compiled as AndroidAsset. | |
webLoadingIcon.LoadUrl(string.Format("file:///android_asset/loading_icon_small.gif")); | |
// this makes it transparent so you can load it over a background | |
webLoadingIcon.SetBackgroundColor(new Color(0,0,0,0)); | |
webLoadingIcon.SetLayerType(LayerType.Software, null); | |
} |
Wow, pretty much like a magic. Huge thanks!
when i check it tablet it show in half of screen
I had to remove webLoadingIcon.SetLayerType(LayerType.Software, null); to play animation.
Thanks! that works
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
it works like a magic.