Android启动画面ProgressBar颜色不会更改

时间:2016-02-05 12:10:49

标签: android splash-screen android-progressbar

我正在我的应用中制作Splash Screen。我必须在我的启动画面中设置ProgressBar。但是ProgressBar显示绿色,我必须使用代码设置白色之后工作一段时间。首先显示绿色,然后它变为白色

要创建ProgressBar我已使用此https://github.com/rahatarmanahmed/CircularProgressView 任何帮助都要得到赞赏。

Java代码:

public class SplashScreenActivity extends Activity {

    // Set Duration of the Splash Screen

    CircularProgressView progressView;
    private static int SPLASH_TIME_OUT = 3000;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Remove the Title Bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        // Get the view from splash_screen.xml
        setContentView(R.layout.splash_screen);


        new Handler().postDelayed(new Runnable() {


            @Override
            public void run() {

                progressView = (CircularProgressView) findViewById(R.id.progress_view);
                progressView.setColor(Color.parseColor("#FFFFFF"));



                finish();
                Intent myIntent = new Intent(SplashScreenActivity.this,
                        MainActivity.class);
                startActivity(myIntent);
            }
        }, SPLASH_TIME_OUT);


    }
}

2 个答案:

答案 0 :(得分:0)

尝试使用此代码即可。

new Handler().postDelayed(new Runnable() {


            @Override
            public void run() {

                progressView = (CircularProgressView) findViewById(R.id.progress_view);
                progressView.getIndeterminateDrawable().setColorFilter(getResources().getColor(R.color.accent_dark),
                        PorterDuff.Mode.SRC_IN);



                finish();
                Intent myIntent = new Intent(SplashScreenActivity.this,
                        MainActivity.class);
                startActivity(myIntent);
            }
        }, SPLASH_TIME_OUT);

答案 1 :(得分:0)

更改代码替换后,在Handler代码查看代码之前,它将完美地放入ProgressBar初始化和setcolor属性:

public class SplashScreenActivity extends Activity {

    // Set Duration of the Splash Screen

    CircularProgressView progressView;
    private static int SPLASH_TIME_OUT = 3000;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Remove the Title Bar
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        // Get the view from splash_screen.xml
        setContentView(R.layout.splash_screen);

     progressView = (CircularProgressView) findViewById(R.id.progress_view);
                    progressView.setColor(Color.parseColor("#FFFFFF"));

        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {

                finish();
                Intent myIntent = new Intent(SplashScreenActivity.this,
                        MainActivity.class);
                startActivity(myIntent);
            }
        }, SPLASH_TIME_OUT);


    }
}