2012-09-06 17 views
6

मैं एंड्रॉइड पर एनिमेशन के लिए नया हूं और मुझे एक साधारण समस्या है ... मेरे पास एक स्पलैश/लोडिंग स्क्रीन है, जिसे मैं पूरा होने पर फीका करना चाहता हूं, फिर ऐप दिखाएं ।एंड्रॉइड फीड आउट लाइनरलाइट कभी शुरू नहीं होता

final Animation fadeOut = AnimationUtils.loadAnimation(this, android.R.anim.fade_out); 
final View splash = findViewById(R.id.homeMainLayout); 
fadeOut.setAnimationListener(new AnimationAdapter() 
{ 
    @Override 
    public void onAnimationEnd(final Animation animation) 
    { 
     splash.setVisibility(View.GONE); 
     findViewById(R.id.homeMainLayout).setVisibility(View.VISIBLE); 
    } 

    /** And the other two methods */ 

}); 
splash.startAnimation(fadeOut); 
:

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/homeParentContainer" 
    style="@style/LayoutWithBgStyle" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <LinearLayout 
     android:id="@+id/homeSplashLayout" 
     style="@style/LayoutWithSplashStyle" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" > 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/homeMainLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentTop="true" 
     android:orientation="vertical" 
     android:visibility="gone" > 
    </LinearLayout> 
</RelativeLayout> 

तब मैं स्प्लैश स्क्रीन बाहर fading और मुख्य स्क्रीन दिखाई करने के दो अलग-अलग दृष्टिकोण की कोशिश की:

मेरे लेआउट (शैलियों सिर्फ एक पृष्ठभूमि छवि सेट) कुछ इस तरह दिखता

तब मैं अपने खुद के एनीमेशन की कोशिश की:

final AlphaAnimation fadeOut = new AlphaAnimation(1.0F, 0.0F); 
fadeOut.setDuration(1000); 
final View splash = findViewById(R.id.homeMainLayout); 
fadeOut.setAnimationListener(new AnimationListener() 
{ 
    @Override 
    public void onAnimationEnd(final Animation animation) 
    { 
     splash.setVisibility(View.GONE); 
     findViewById(R.id.homeMainLayout).setVisibility(View.VISIBLE); 
    } 

    /** And the other two methods */ 

}); 
splash.startAnimation(fadeOut); 

और मैं करने के लिए मिल प्रारंभएनीमेशन कोड, लेकिन एनीमेशन कभी शुरू नहीं होता है, और मुझे कभी भी एनीमेशन एंड() कॉल नहीं मिलता है। एनीमेशन वास्तव में चलाने के लिए मुझे शामिल करने के लिए क्या भूल गया है?

उत्तर

1

मैं एक लापरवाही प्रोग्रामर रहा हूं।

final View splash = findViewById(R.id.homeMainLayout); 

वास्तव में पढ़ना चाहिए:

final View splash = findViewById(R.id.homeSplashLayout); 

कुछ है कि अदृश्य है बाहर fading क्योंकि मैं क्या चाहते थे नहीं है।

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^