1

Ich versuche, den Fortschrittsbalken in 3 Sekunden auszublenden, aber es funktioniert nicht.Fortschrittsbalken animiert nicht

// Animate progress bar. 
    progressBar1 = (ProgressBar) findViewById(R.id.mainImageView1); 
    ObjectAnimator animato = ObjectAnimator.ofFloat(progressBar1, "alpha", 1.0f, 0.0f); 
    animato.setInterpolator(new DecelerateInterpolator()); 
    animato.setDuration(3000); 
    animato.start(); 

Layout (xml)

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    android:background="#FFFFFF"> 

    <ImageView 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:src="@drawable/ic_launcher" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="168dp" 
     android:id="@+id/mainImageView1"/> 

    <ProgressBar 
     style="?android:attr/progressBarStyleHorizontal" 
     android:layout_height="wrap_content" 
     android:layout_width="match_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_marginBottom="48dp" 
     android:layout_marginLeft="30dp" 
     android:layout_marginRight="30dp" 
     android:indeterminate="true" 
     android:alpha="0.9"/> 

</RelativeLayout> 

Und schließlich, was ich mit "Arbeit" zu verstehen ist, dass die Fortschrittsbalken verblassen nicht ab.

+0

Ihr Code sieht so weit in Ordnung, geben Sie bitte Ihre ProgressBar xml veröffentlichen, und im Detail zu erklären, was „es tut nicht arbeiten "bedeutet. –

Antwort

0

Verwenden AlphaAnimation statt ObjectAnimator >>>

AlphaAnimation fade = new AlphaAnimation(1.0f, 0.0f); // from 1 to 0 transparancy 
fade.setDuration(1000); 
fade.setFillAfter(true) //Keeps ProgressBar at 0 opacity after animation 
myProgressBar.startAnimation(fadeOutAnimation); 

Hoffe es funktioniert :)

BTW haben Sie nicht id auf Ihre Statusleiste zugewiesen, assign ID zu Ihrem Fortschrittsbalken

Dann deklariere eine Variable namens myProgressBar

dann initialisiere sie mit der entsprechenden ID deines Fortschrittsbalkens.

+0

Sorry, aber es stürzt sofort ab. – user7280056

+0

Hallo Buddy, hat Uhh Hilfe bekommen ?? oder Shud Ich erzähle noch ein paar Dinge ?? Sorry für spät – Ritik

1

Sie versuchen, Ihr Image auf eine ProgressBar mit dieser Linie zu werfen:

progressBar1 = (ProgressBar) findViewById(R.id.mainImageView1); 

R.id.mainImageView1 zu Ihrem Image in Ihrem xml zugewiesen wird.

eine ID zu Ihrem ProgressBar in Ihrem xml zuordnen:

<ProgressBar 
    ... 
    android:id="@+id/progress_bar" 
/> 

und dann

progressBar1 = (ProgressBar) findViewById(R.id.progress_bar); 
Verwandte Themen