2016-06-16 3 views
2

내가 매니페스트의 주제와 태그 windowBackground를 사용하여 안드로이드 활동의 시작을 설정하는 방법을 잘 의식 해요 시작 windowBackground.안드로이드 변화는 프로그래밍 응용 프로그램에

최근에 클라이언트가 "하루 중 일부 이벤트에 따라 스플래시 화면을 변경"하는 메시지가 나타났습니다. 나는 그것을 할 수없는 것을 거의 확신하지만이 코드로에게 기회를 주기로 결정 :

public class MyApplication extends Application { 

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

     int random = (int) Math.abs(System.currentTimeMillis() % 3); 

     switch (random) { 

      case 0: 
       setTheme(R.style.FullscreenTheme1); 
       break; 

      case 1: 
       setTheme(R.style.FullscreenTheme2); 
       break; 

      default: 
       setTheme(R.style.FullscreenTheme3); 
       break; 
     } 
    } 
} 

분명이 작동하지 않습니다.

이미 누군가를 공언하려고했거나 더 좋은 아이디어가 있습니까?

감사합니다

편집 :

시작 화면이 쉽게 될 것으로 보여주기 위해 가짜 활동이나 조각을 생성하지만, 응용 프로그램 시작에 불쾌한 흰색 (또는 검은 색 테마에 따라) 것을 플래시를 왼쪽합니다 .

이 질문은 매니페스트의 하드 코딩과 동일한 결과를 사용하여 프로그래밍 방식으로 스플래시 화면을 변경하는 가능성에 대한 것입니다.

+0

이 작업을 수행 할 수 있었습니까? – thiagolr

+1

죄송합니다. 불가능한 것 같습니다. 앱이 시작될 때 시작 화면을 설정할 수 있지만 변경할 수는 없습니다 (https://www.bignerdranch.com/blog/splash-screens-the-right-way/ ). 또는보기를 만들 수 있습니다 당신이 원할 때마다 변경할 수있는 앱을 열 때 빈 화면의 절반을 두 번 줄 수 있다면 그 것처럼 작동합니다. –

답변

0

Splash를 제거하고 원하는 이미지를 n 초 동안 표시하는 전체 화면으로 활동을 만들어 시뮬레이트하면 어떨까요?

0

배경을 변경하려는 경우이 방법을 사용해보십시오. 작업 표시 줄의 색상과 모양은 거의 동일한 방식으로 수행 할 수 있습니다.

package com.example; 

    import java.util.ArrayList; 

    public class WelcomeFragment extends Fragment { 
     private LinearLayout mainLayout; 

     //since you seem only interested in the background color changing, using a theme might seem to be overkill 
     //that is if its for a very short time 
     //but then a theme is better if you are concerned about branding 
     //what i have here is basically to cahnge the background color 
     @Override 
     public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
      View v = inflater.inflate(R.layout.fragment_welcome, container, false); 
mainLayout = (LinearLayout) v.findViewById(R.id.main_layout); 
      colorList.add(R.color.accent); 
      colorList.add(R.color.primary_light); 
      colorList.add(R.color.secondary_light); 
      colorList.add(R.color.secondary); 
      colorList.add(R.color.secondary_dark); 
      colorList.add(R.color.colorPrimaryDark); 
      colorList.add(R.color.primary_dark); 
      colorList.add(R.color.primary); 

      return v; 
     } 

     ArrayList<Integer> colorList = new ArrayList<>(); 

     @Override 
     public void onViewCreated(View view, Bundle savedInstanceState) { 
      new CountDownTimer((1000 * 14), 1000) {//set my timer to 14 seconds, restarts if a certain condition is not met 
      //set the timing to appropriate values or if you are just interested in a particular event do this in that section 
       public void onTick(long millisUntilFinished) { 
        //do update here 
        mainLayout.setBackgroundColor(getResources(). 
          getColor(colorList.get((int) (millisUntilFinished/1000) % 7))); 
       } 

       public void onFinish() { 
        if (!done) 
         this.start(); 
       } 
      }.start(); 

      super.onViewCreated(view, savedInstanceState); 
     } 
    } 

이는 현재 활동에 적용됩니다.

+0

나는 _EDIT_에 진술 했으므로 유형 스플래시 화면이 아니므로 기대됩니다. –

관련 문제