クラス ProgressIndicatorView に次のものがあります。ビューを使用すると、以下の 5 つの長方形が保持されます。
ユーザーが「Fortsæt」ボタンを押すと、ビュー内の次の長方形の色を完全に不透明に設定するビュー メソッド setProgressIndicator(int step) を呼び出します。メソッドは次のようになります。
public void setProgressIndicator(int activeStep) {
// Fade IN
TransitionDrawable transition = (TransitionDrawable) this.getChildAt(activeStep-1).getBackground();
transition.startTransition(transitionTime);
}
initメソッドは次のようになります
private void init(Context context) {
this.setOrientation(LinearLayout.HORIZONTAL);
transitionColor = getResources().getDrawable(R.drawable.colortransition);
for (int i = 0; i < squareAmount; i++) {
ImageView loadingPiece = new ImageView(context);
//loadingPiece.setBackgroundColor(transparentWhite);
loadingPiece.setBackgroundDrawable(transitionColor);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0,
LinearLayout.LayoutParams.FILL_PARENT, 1.0f);
lp.setMargins(0, 15, 4, 15);
this.addView(loadingPiece, lp);
}
}
リソースとして静的な背景色を使用する場合、このメソッドは完全に機能しますが、transitioncolor ドローアブルを使用する場合は機能しません。問題の原因について何か提案はありますか?
編集:明確にするために、 this.getChildAt(activeStep-1).setBackgroundColor(opaqueWhite); を使用すると、ビューは次のようになります。
しかし、setProgressIndicator の現在の実装を使用すると、次のようになります。
これが起こる原因は何ですか?
編集:この問題の原因が特定できない場合、この効果を達成できる別のアプローチはありますか?