/// <summary> /// 初始化 /// </summary> /// <param name="context"></param> private void Init(Context context) { iv_Loading = new ImageView(context); iv_Loading.SetBackgroundResource(Resource.Drawable.Anime_LoadingProgress); ad_Loading = iv_Loading.Background as AnimationDrawable; this.SetView(iv_Loading); this.SetCanceledOnTouchOutside(true); }
/// <summary> /// Initializes a new instance of the <see cref="AViewParticleEngine.ParticleSystem"/> class with a AnimationDrawable. /// </summary> /// <param name="a">The parent activity.</param> /// <param name="maxParticles">Max particles.</param> /// <param name="animation">AnimationDrawable to display.</param> /// <param name="timeToLive">Time to live.</param> public ParticleSystem(ViewGroup rootView, int maxParticles, AnimationDrawable animation, long timeToLive) : this(rootView, maxParticles, timeToLive) { // Create the particles for (int i = 0; i < mMaxParticles; i++) { mParticles.Add(new AnimatedParticle(animation)); } }
public override void OnWindowFocusChanged(bool hasFocus) { if (hasFocus) { ImageView imageView = FindViewById <ImageView>(Resource.Id.animated_android); AnimationDrawable animation = (AnimationDrawable)imageView.Drawable; animation.Start(); } }
private void AddBackgroundAnimations() { CoordinatorLayout rootLayout = (CoordinatorLayout)FindViewById(Resource.Id.root_layout); AnimationDrawable animationDrawable = (AnimationDrawable)rootLayout.Background; animationDrawable.SetEnterFadeDuration(2000); animationDrawable.SetExitFadeDuration(4000); animationDrawable.Start(); }
public override void OnBackPressed() { base.OnBackPressed(); if (mLoadingAnim != null) { mLoadingAnim.Stop(); mLoadingAnim = null; } }
public DefaultFooter(Activity context) { MainContext = context; animationLoading = new AnimationDrawable(); foreach (var src in loadingAnimSrcs) { animationLoading.AddFrame(ContextCompat.GetDrawable(context, src), 150); animationLoading.OneShot = (false); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_drawable_animation); _alarmDrawable = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.alarm_animation_24); _imageView = FindViewById <ImageView>(Resource.Id.activity_drawable_animation_imageView); _imageView.SetImageDrawable(_alarmDrawable); }
public AnimatedParticle(AnimationDrawable animationDrawable) { mAnimationDrawable = animationDrawable; mImage = ((BitmapDrawable)mAnimationDrawable.GetFrame(0)).Bitmap; // If it is a repeating animation, calculate the time mTotalTime = 0; for (int i = 0; i < mAnimationDrawable.NumberOfFrames; i++) { mTotalTime += mAnimationDrawable.GetDuration(i); } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.LaunchScreen); ImageView imageView = FindViewById <ImageView>(Resource.Id.animated_android); AnimationDrawable animation = (AnimationDrawable)imageView.Drawable; animation.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.BronLayout); //---Переменные для работы NAvigationView drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); navView = FindViewById <NavigationView>(Resource.Id.nav_view); DrawerImage = FindViewById <ImageView>(Resource.Id.Button_menu); LoaderView = FindViewById <RelativeLayout>(Resource.Id.LoaderView); LoaderImage = FindViewById <ImageView>(Resource.Id.LoaderImage); //---Переменные для работы с Activity ListViewTrips = FindViewById <ListView>(Resource.Id.ListViewTrips); SpinnerRouts = FindViewById <Spinner>(Resource.Id.SpinnerRouts); SpinnerPoStart = FindViewById <Spinner>(Resource.Id.SpinnerPoStart); SpinnerPoEnd = FindViewById <Spinner>(Resource.Id.SpinnerPoEnd); TextViewData = FindViewById <TextView>(Resource.Id.TextViewData); TextViewData.Click += TextViewData_Click; SpinnerRouts.ItemSelected += SpinnerRouts_ItemSelected; SpinnerPoStart.ItemSelected += SpinnerPoStart_ItemSelected; SpinnerPoEnd.ItemSelected += SpinnerPoEnd_ItemSelected; AnimationLoader = (AnimationDrawable)LoaderImage.Drawable; AnimationLoader.Start(); ListViewTrips.DividerHeight = 0; ListViewTripsParmetr = ListViewTrips.LayoutParameters; ListViewTrips.ItemClick += ListViewTrips_ItemClick; DrawerImage.Click += DrawerImage_Click; HeaderView = LayoutInflater.From(this).Inflate(Resource.Layout.drawer_header, null, false); navView.AddHeaderView(HeaderView); navView.NavigationItemSelected += NavView_NavigationItemSelected; new Thread(new ThreadStart(delegate //поток для загрузки данных { ObratPO = new List <IApi>(); TripDate = DateTime.Today; RunOnUiThread(() => TextViewData.Text = TripDate.ToString("dd.MM.yyyy")); routs = Routs.GetMarshruts(); routs[0].GetPromPynkt(); for (int i = routs[0].PromPynkt.Count - 1; i >= 0; i--) { ObratPO.Add(routs[0].PromPynkt[i]); } RunOnUiThread(() => SpinnerRouts.Adapter = new RoutAdapter(this, routs)); RunOnUiThread(() => SpinnerPoStart.Adapter = new PromPynktAdapter(this, routs[0].PromPynkt)); RunOnUiThread(() => SpinnerPoEnd.Adapter = new PromPynktAdapter(this, ObratPO)); trips = Trips.GetTripsOnDate(TripDate.ToString("yyyy-MM-dd"), routs[0].PromPynkt[0].id.ToString(), ObratPO[0].id.ToString(), routs[0].id.ToString()); ListViewTripsParmetr.Height = Convert.ToInt32(function.convertDpToPixel(90, this)) * trips.Count; RunOnUiThread(() => ListViewTrips.Adapter = new TripsAdapter(this, trips)); RunOnUiThread(() => AnimationLoader.Stop()); RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible); })).Start(); }
private void btn5Clicked(object sender, EventArgs e) { ImageView imageView = new ImageView(this); imageView.SetBackgroundResource(Resource.Drawable.spin_animation); AnimationDrawable drawable = (AnimationDrawable)imageView.Background; drawable.Start(); hud = KK.Create(this).SetLabel("Loading...").SetCustomView(imageView); hud.Show(); ScheduleDismiss(); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Load the animation from resources Animation = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.animation); ImageView imageView = FindViewById <ImageView>(Resource.Id.imageView1); imageView.SetImageDrawable(Animation); }
public void mostrarViewLoadingSecurity() { customDialog.SetCancelable(false); customDialog.SetContentView(Resource.Layout.dialogoLoadingBcoSecurity); customDialog.Window.SetStatusBarColor(Color.Transparent); customDialog.OwnerActivity = activity; ivLoader = customDialog.FindViewById <ImageView>(Resource.Id.gifLoadingBcoSecurity); ivLoader.SetBackgroundResource(Resource.Animation.animationloader); AnimationDrawable frameAnimation = (AnimationDrawable)ivLoader.Background; frameAnimation.Start(); customDialog.Show(); }
public override void OnWindowFocusChanged(bool hasFocus) { if (customProgressDialog == null) { return; } ImageView imageView = customProgressDialog.FindViewById <ImageView>(Resource.Id.loadingImageView); AnimationDrawable animationDrawable = (AnimationDrawable)imageView.Background; animationDrawable.Start(); base.OnWindowFocusChanged(hasFocus); }
protected override void OnDestroy() { base.OnDestroy(); if (mPlayerView != null && mPlayerView.DrawingCacheEnabled) { mPlayerView.DestroyDrawingCache(); } if (mLoadingAnim != null) { mLoadingAnim.Stop(); mLoadingAnim = null; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); //MapView = FindViewById<WebView>(Resource.Id.MapView); drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout); navView = FindViewById <NavigationView>(Resource.Id.nav_view); LoaderView = FindViewById <RelativeLayout>(Resource.Id.LoaderView); LoaderImage = FindViewById <ImageView>(Resource.Id.LoaderImage); ListViewMarsh = FindViewById <ListView>(Resource.Id.ListViewMarsh); ListViewPO = FindViewById <ListView>(Resource.Id.ListViewPO); ImageView DrawerImage = FindViewById <ImageView>(Resource.Id.Button_menu); ButtonBron = FindViewById <Button>(Resource.Id.ButtonBron); DrawerImage.Click += DrawerImage_Click; ButtonBron.Click += ButtonBron_Click; AnimationLoader = (AnimationDrawable)LoaderImage.Drawable; AnimationLoader.Start(); HeaderView = LayoutInflater.From(this).Inflate(Resource.Layout.drawer_header, null, false); navView.AddHeaderView(HeaderView); navView.NavigationItemSelected += NavView_NavigationItemSelected; ListViewMarsh.ChoiceMode = ChoiceMode.Single; ListViewMarsh.DividerHeight = 0; ListViewMarsh.ItemClick += ListViewMarsh_ItemClick; ListViewPO.DividerHeight = 0; var paramMarsh = ListViewMarsh.LayoutParameters; var paramPO = ListViewPO.LayoutParameters; //MapView.Settings.JavaScriptEnabled = true; new Thread(new ThreadStart(delegate //поток для загрузки данных { var user = User.GetInstance(0, "", "", GetString(Resource.String.token)); marshruts = Routs.GetMarshruts(); foreach (var item in marshruts) { item.GetPromPynkt(); } //RunOnUiThread(() => MapView.LoadUrl("http://orion38.pro/maps/maps.php?url_map=" + marshruts[0].url_map)); paramMarsh.Height = Convert.ToInt32(function.convertDpToPixel(45, this)) * marshruts.Count; paramPO.Height = Convert.ToInt32(function.convertDpToPixel(35, this)) * (marshruts[0].PromPynkt.Count + 1); RunOnUiThread(() => ListViewMarsh.Adapter = new RoutAdapter(this, marshruts)); RunOnUiThread(() => ListViewPO.Adapter = new PromPynktAdapter(this, marshruts[0].PromPynkt)); RunOnUiThread(() => AnimationLoader.Stop()); RunOnUiThread(() => LoaderView.Visibility = ViewStates.Invisible); })).Start(); }
/// <summary> /// Caches all animations. /// </summary> private void CacheAnimations() { try { foreach (AnimationType animation in Enum.GetValues(typeof(AnimationType))) { if (animation == AnimationType.None || animation == AnimationType.ShirtPullDown) { continue; } var animationDrawable = new AnimationDrawable(); using (var stream = new StreamReader(Assets.Open(string.Format("{0}.xml", animation)))) { var document = XDocument.Load(stream); var root = document.Root; var elements = root.Descendants(); foreach (var element in elements) { var drawable = ReadAttribute(element, "drawable"); var duration = ReadAttribute(element, "duration"); var bitmapStringId = drawable.Substring(drawable.IndexOf('/') + 1); var resID = Resources.GetIdentifier(bitmapStringId, "drawable", PackageName); BitmapFactory.Options options = new BitmapFactory.Options(); options.InJustDecodeBounds = false; options.InPreferredConfig = Bitmap.Config.Rgb565; options.InDither = true; options.InSampleSize = 2; options.InPurgeable = true; using (Bitmap bitmap = BitmapFactory.DecodeResource(Resources, resID, options)) { BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap); animationDrawable.AddFrame(bitmapDrawable, int.Parse(duration)); } } // cache animation _animationsDrawable.Add(animation.ToString(), animationDrawable); } } } catch (Exception ex) { _statusTextView.Text = ex.ToString(); } }
public void SetUiEnable(bool enable) { if (remoteSettings.SendVehicleDataToMailbox) { sliderLabel.Text = "Slider:"; } else { sliderLabel.Text = "Motor:"; } sensor1.Enabled = enable; sensor2.Enabled = enable; sensor3.Enabled = enable; sensor4.Enabled = enable; seekBar.Enabled = enable; circle.Enabled = enable; Android.Graphics.Color color = new Android.Graphics.Color(0x99, 0x99, 0x99); if (!enable) { circle.SetImageResource(Resource.Drawable.aniGray); circleAnimation.Stop(); } else { color = new Android.Graphics.Color(0xf2, 0x61, 0x00); circle.SetImageResource(Resource.Drawable.animation); circleAnimation = (AnimationDrawable)circle.Drawable; circleAnimation.Start(); if (remoteSettings.SensorValueToSpeech) { sensor1.Enabled = true; sensor2.Enabled = true; sensor3.Enabled = true; sensor4.Enabled = true; } else { sensor1.Enabled = false; sensor2.Enabled = false; sensor3.Enabled = false; sensor4.Enabled = false; } } angleText.SetTextColor(color); speedText.SetTextColor(color); sliderText.SetTextColor(color); angleLabel.SetTextColor(color); speedLabel.SetTextColor(color); sliderLabel.SetTextColor(color); }
private void RenderGif() { AnimationDrawable test = new AnimationDrawable(); test.OneShot = false; for (int i = 1; i < 90; i++) { Drawable d = DrawableConverter.GetDrawableFromAssets("gif/i" + i.ToString() + ".png", this); test.AddFrame(d, 1); } iView.SetImageDrawable(test); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.activity_imageandbutton); // Load the animation from resources _asteroidDrawable = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.spinning_asteroid); ImageView imageView = FindViewById <ImageView>(Resource.Id.imageView1); imageView.SetImageDrawable(_asteroidDrawable); Button spinAsteroidButton = FindViewById <Button>(Resource.Id.button1); spinAsteroidButton.Text = Resources.GetString(Resource.String.title_spinasteroid); spinAsteroidButton.Click += (sender, args) => _asteroidDrawable.Start(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_imageandbutton); _asteroidDrawable = (AnimationDrawable)Resources.GetDrawable(Resource.Drawable.spinning_asteroid); var imageView = FindViewById <ImageView> (Resource.Id.imageView1); imageView.SetImageDrawable(_asteroidDrawable); var spinAsteroidButton = FindViewById <Button> (Resource.Id.button1); spinAsteroidButton.Text = Resources.GetString(Resource.String.title_spinasteroid); spinAsteroidButton.Click += (s, e) => _asteroidDrawable.Start(); }
/// <summary> /// Create an animated bitmap /// </summary> public static Drawable GetAnimatedDrawable(Resources res, string name, int frames, int duration, bool loop) { var animation = new AnimationDrawable(); var bitmapFrames = new List <Bitmap>(frames); for (var i = 0; i < frames; i++) { bitmapFrames.Add(GetAnimationFrameBitmap(name, i)); } // TODO: Load drawable better, like from cache bitmapFrames.ForEach(f => animation.AddFrame(new BitmapDrawable(res, f), duration)); animation.OneShot = !loop; animation.Start(); return(animation); }
/// <summary> /// Gets the rect with animation. /// </summary> /// <returns>Drawable.</returns> public Drawable GetRectWithAnimation() { var builder = DrawableTextView.TextDrwableBuilder.Rect(); var animationDrawable = new AnimationDrawable(); for (var i = 10; i > 0; i--) { var frame = builder.Build(i.ToString(), RandomColor, RandomColor); animationDrawable.AddFrame(frame, 1200); } animationDrawable.OneShot = false; animationDrawable.Start(); return(animationDrawable); }
void SetAnimation() { var frameAnimation = new AnimationDrawable(); foreach (var img in this.images) { frameAnimation.AddFrame(img, 1000); } this.RunOnUiThread(() => { var imageButton = FindViewById <Button> (Resource.Id.AllFilmsButton); imageButton.SetBackgroundDrawable(frameAnimation); frameAnimation.Start(); }); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button play = FindViewById <Button>(Resource.Id.btn_paly); Button stop = (Button)FindViewById(Resource.Id.btn_stop); ImageView imageView = FindViewById <ImageView>(Resource.Id.anim); // 获取AnimationDrawable动画对象 AnimationDrawable anim = (AnimationDrawable)imageView.Background; // 开始播放动画 play.Click += delegate { anim.Start(); }; // 停止播放动画 stop.Click += delegate { anim.Stop(); }; }
private void PauseAnimation(IMenuItem target) { Drawable currentFrame; Drawable checkFrame; AnimationDrawable animation; AnimationDrawable newAnimation; newAnimation = new AnimationDrawable(); RunOnUiThread(() => { animation = (AnimationDrawable)target.Icon; animation.Stop(); currentFrame = animation.Current; for (int i = 0; i < animation.NumberOfFrames; i++) { checkFrame = animation.GetFrame(i); if (checkFrame == currentFrame) { for (int k = i; k < animation.NumberOfFrames; k++) { newAnimation.AddFrame(animation.GetFrame(k), 100); } for (int k = 0; k < i; k++) { newAnimation.AddFrame(animation.GetFrame(k), 100); } break; } } target.SetIcon(newAnimation); }); }
private void InitAnimation() { try { if (mVideoPrepareLayout == null) { mPlayerView = FindViewById <VideoPlayerView>(Resource.Id.playerView); mBufferingIndicator = FindViewById <View>(Resource.Id.buffering_indicator); mVideoPrepareLayout = FindViewById <RelativeLayout>(Resource.Id.video_start); mAnimImageView = FindViewById <ImageView>(Resource.Id.bili_anim); mPrepareText = FindViewById <TextView>(Resource.Id.video_start_info); } mVideoPrepareLayout.Visibility = ViewStates.Visible; startText += "【完成】\n解析视频地址..."; mPrepareText.SetText(startText, BufferType.Normal); mLoadingAnim = (AnimationDrawable)mAnimImageView.Background; mLoadingAnim.Start(); } catch (Java.Lang.Exception e) { Log.Error(TAG, "InitAnimation--" + e.ToString()); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); ImageView circle = (ImageView)FindViewById <ImageView> (Resource.Id.circle); circleAnimation = (AnimationDrawable)circle.Drawable; circle.Touch += delegate(object sender, View.TouchEventArgs e) { if (e.Event.Action == MotionEventActions.Down) { Console.WriteLine("Circle was pressed"); circleAnimation.Stop(); circle.SetImageResource(Resource.Drawable.circle); } if (e.Event.Action == MotionEventActions.Up) { Console.WriteLine("Circle is not pressed"); circle.SetImageDrawable(circleAnimation); circleAnimation.Run(); //circleAnimation.Start(); } }; //SetContentView(new CircleView(this)); }
public RunnableAnonymousInnerClassHelper(AnimationDrawable animDrawable) { this.animDrawable = animDrawable; }
protected override async void OnCreate ( Bundle bundle ) { //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 4 : {0}", // GC.GetTotalMemory(false)); base.OnCreate(bundle); SetContentView(Resource.Layout.SplashScreenLayout); _progressCount = FindViewById <TextView>(Resource.Id.ProgressCount); ImageView splashProgress = FindViewById <ImageView>(Resource.Id.SplashProgress); splashProgress.SetBackgroundResource(Resource.Drawable.ProgressSphere); AnimationDrawable splashAnimation = splashProgress.Background as AnimationDrawable; Exception loadingException = null; //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 5 : {0}", // GC.GetTotalMemory(false)); splashAnimation?.Start(); _loadingContext = this; if (_loadingTask == null) { _loadingTask = CreateLoadingTask ( GetString(Resource.String.SplashTextFormat), updateText: (progressText) => UpdateText(progressText), getContext: () => { return(GetContext()); } ); } //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 6 : {0}", // GC.GetTotalMemory(false)); try { await _loadingTask; } catch (Exception exception) { loadingException = exception; } finally { _loadingTask = null; splashAnimation?.Stop(); splashAnimation?.Dispose(); splashAnimation = null; splashProgress = null; } /*// http://stackoverflow.com/questions/477572/strange-out-of-memory-issue-while-loading-an-image-to-a-bitmap-object * * Java.Lang.JavaSystem.RunFinalization(); * Java.Lang.JavaSystem.Gc(); * Java.Lang.JavaSystem.RunFinalization(); * System.Runtime.GCSettings.LargeObjectHeapCompactionMode * = System.Runtime.GCLargeObjectHeapCompactionMode.CompactOnce; * GC.Collect();*/ if (loadingException != null) { AndroidCrapApplication.ShowExceptionAndExit(this, loadingException); return; } //AndroidCrapApplication.ApplicationLogger.LogDebug("MEMORY 7 : {0}", // GC.GetTotalMemory(false)); }