0

当我运行它时,我的应用程序会显示一个带有动画 GIF 的小弹出窗口。问题是主布局(空白)在消失之前显示了几微秒,然后弹出窗口显示。我试过使用 mainLayout.setVisibility(View.INVISIBLE) 但它没有任何区别。有什么方法可以改变行为,使主布局根本不显示。

这是主要活动 java 文件:

public class MainActivity extends Activity {

      @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    Intent intent = new Intent(this,AnimePopupActivity.class);
    startActivity(intent);
    finish();
      }
}

这是主要活动调用的 java 文件:

public class AnimePopupActivity extends Activity {

        @Override
        protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        InputStream stream = null;
        try{
            stream = getAssets().open("382.gif");
        } catch (IOException e) {
            e.printStackTrace();
        }
        GifMovieView view = new GifMovieView(this,stream);
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);

        mainLayout = new LinearLayout(this);
        //mainLayout.setVisibility(View.INVISIBLE);
        setContentView(mainLayout);

        layout = new LinearLayout(this);
        popUp = new PopupWindow(this);
        params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

        layout.setOrientation(LinearLayout.VERTICAL);
        layout.addView(view,params);
        popUp.setContentView(layout);


        new Handler().postDelayed(new Runnable(){
            public void run(){
                popUp.showAtLocation(mainLayout, Gravity.CENTER, 10, 10);
                popUp.update(-1,-1,240,320);    

            }
        },100);
4

0 回答 0