2017-02-10 99 views
-2

我有一個帶有進度條的dummylaylayView。android-在加載主佈局之前加載進度條佈局

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:id="@+id/progressbar"> 
      <ProgressBar 
      style="?android:attr/progressBarStyleLarge" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_centerVertical="true" 
      android:layout_centerHorizontal="true" 
      android:id="@+id/progressBar" /> 
    </RelativeLayout> 

當我的應用程序啓動時,我需要這個RelativelayoutView出現5秒鐘,並應該有或沒有動畫。

+0

[使用Glide庫完成圖像加載完成後設置進度條的可見性]的可能的副本(http://stackoverflow.com/questions/26054420/set-visibility-of-progress-bar-gone-on-completion -of-image-loading-using-glide-l) –

回答

1

我不知道我理解你的問題,但我建議你寫這樣的事情在你的活動:

private Handler mHandler; 

@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.your_layout); 

    mHandler = new Handler(Looper.getMainLooper()); 
    mHandler.postDelayed(new Runnable() { 
      public void run() { 
       // hide your progress bar 
       findViewById(R.id.progressBar).setVisibility(View.GONE); 
       // or finish this activity and start a new one 
       startActivity(new Intent(MyActivity.this, MySecondActivity.class)); 
      } 
    }, 5000); 
} 

@Override 
public void onDestroy() { 
    super.onDestroy(); 
    mHandler.removeCallbacks(null); 
} 

而且我覺得你應該android:indeterminate="true"屬性添加到您的進度條。

希望它有幫助。乾杯。

+0

謝謝先生......完美..這就是我需要的......我可以通過創建一個進度條的android資源文件來做同樣的事情,以便我可以隱藏標題欄?.. – Simon

+0

如果您想要隱藏活動的標題欄,您必須在清單中爲特定活動設置主題屬性:'android:theme =「@ style/Theme.AppCompat.Light.NoActionBar」 '..如果以前的答案是正確的,請將我的帖子標記爲正確的! –

+0

如果我讓'android:theme =「@ style/Theme.AppCompat.Light.NoActionBar」'改變,那麼我的整個佈局將沒有任何操作欄......我只需要進度欄佈局就可以使用noAction欄。 .. 謝謝你,先生... – Simon