2 つの実行中のコンポーネントを含むスプラッシュ スクリーンを表示する必要があります。
プログレスバーは簡単に表示でき、画像もロードできますが、 .gif画像は使いたくありません。
どうすればこれを達成できますか?
スナップショーツはこちら。
2 つの実行中のコンポーネントを含むスプラッシュ スクリーンを表示する必要があります。
プログレスバーは簡単に表示でき、画像もロードできますが、 .gif画像は使いたくありません。
どうすればこれを達成できますか?
スナップショーツはこちら。
カスタムの進行状況を表示したい場合は、画像を使用して回転させることができます<animated-rotate>
drawable フォルダー内に xml を作成し、
custom_progress_bar.xml
<?xml version="1.0" encoding="utf-8"?>
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/progres_image"
android:pivotX="50%"
android:pivotY="50%" />
次に、レイアウトの ProgressBar に追加します。
<ProgressBar
android:id="@+id/video_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/custom_progrress_bar" />
以下のコードを使用できます。ここでimageview を ロードするのは、上で示した GIF 画像です。上記の質問に示されているように、 loadingTextは TextView "Loading .." です。
コードの最後の行で述べたように、それに応じてスレッド内のProgressBarの進行状況マークを管理するだけです..
ImageView loading = (ImageView) findViewById(R.id.loading);
ProgressBar loadingProgress = (ProgressBar) findViewById(R.id.loadingProgress);
TextView loadingText = (TextView) findViewById(R.id.loadingText);
/***
* Starting Animation Progress bar
*/
Animation anim = AnimationUtils.loadAnimation(this, R.anim.looprotate);
anim.setRepeatCount(-1);
anim.setRepeatMode(Animation.RESTART);
loading.startAnimation(anim);
loading.setVisibility(View.VISIBLE);
loadingProgress.setVisibility(View.VISIBLE);
loadingProgress.setProgress(10);
loadingText.setVisibility(View.VISIBLE);
loadingText.setText("Connecting");
loadingProgress.setProgress(10);
to
loadingProgress.setProgress(100);
res の Anim フォルダーにanim.xmlを作成します。
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:repeatCount="infinite"
android:repeatMode="restart"
android:duration="1000"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:toDegrees="360" >
</rotate>