在android xamarin中加载进度条的动画启动画面

时间:2016-03-08 04:34:49

标签: c# android visual-studio xamarin

我正在使用Visual Studio 2015中的xamarin monoandroid创建一个带有进度条的启动画面 我看过很多关于启动画面的帖子只有徽标,但我需要动画启动画面和动画加载进度条。

SplashScreen.cs

namespace Splash_Screen
{
      [Activity(Label = "Splash Screen App", MainLauncher = true, NoHistory = true, Icon = "@drawable/icon")]
    public class SplashScreen : Activity
    {
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            //Display Splash Screen for 4 Sec  
            SetContentView(Resource.Layout.SplashLayout);
               TextView loadingText = FindViewById<TextView>(Resource.Id.textView1);
            ProgressBar mProgress = (ProgressBar)FindViewById(Resource.Id.progress_bar);
            Thread.Sleep(4000);
            //Start Activity1 Activity  
            StartActivity(typeof(MainActivity));
        }
    }
}

SplashLayout.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/splash_screen_bg"
    android:gravity="center"
    android:orientation="vertical">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="loading"
        android:textAppearance="@android:style/TextAppearance.Medium.Inverse"
        android:textColor="@android:color/background_light" />
    <ProgressBar
        android:id="@+id/progress_bar"
        style="?android:attr/progressBarStyleHorizontal"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:max="100" />
</LinearLayout>

splash_screen_bg.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle" >

  <gradient
      android:angle="90"
      android:centerColor="#FF223333"
      android:endColor="@android:color/black"
      android:startColor="@android:color/black" />

</shape>

我得到一个空白的黑屏而不是闪屏。这里应该做什么

我需要像这张没有动作栏的图片

enter image description here

0 个答案:

没有答案