0

こんにちは、画面をフラッシュライトや警察のサイレンのようなものに変えるアプリを構築しようとしています.2.3 Androidを搭載したGalaxy gioでテストされています.2.3 +デバイスでは、最初の色でスタックします. logcat のエラーは、アクティビティに対してフレームがスキップされすぎています。遅延を減らそうとしましたが、うまくいきません。4.0 + android バージョンでしか動作しません。

public class MainActivity extends Activity {

RelativeLayout soli;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //full screeen
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
        WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //full screen
    setContentView(R.layout.activity_main);
    //brightness full
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.screenBrightness = 100 / 100.0f;
    //brightness full
    soli = (RelativeLayout) findViewById(R.id.soli);

}
public void soheil(){


    final RelativeLayout soli = ((RelativeLayout) findViewById(R.id.soli));
    ColorDrawable f = new ColorDrawable(0xff00ff00);
    ColorDrawable f2 = new ColorDrawable(0xffff0000);
    ColorDrawable f3 = new ColorDrawable(0xff0000ff);
    ColorDrawable f4 = new ColorDrawable(0xff0000ff);

    AnimationDrawable a = new AnimationDrawable();
    int DELAY=1500;
    a.addFrame(f, DELAY);
    a.addFrame(f2, DELAY);
    a.addFrame(f3, DELAY);
    a.addFrame(f4, DELAY);
    a.setOneShot(false);

    soli.setBackgroundDrawable(a); //  is deprecated  API 16
    // soli.setBackground(a); //  API 16
    a.start();




}
@Override
protected void onStart() {
super.onStart();soheil();

}
@Override
protected void onDestroy() {
super.onDestroy();

}
@Override
protected void onResume() {
super.onResume();

}
@Override
protected void onPause() {
super.onDestroy();

}
@Override
protected void onStop() {
super.onDestroy();

}
4

1 に答える 1

0

気にしないで見つけた!これはおそらく他の人に役立つ答えです。私はすべてのグラフィックを touchlistener イベントに配置しましたが、すべてうまくいっています。

于 2013-05-17T23:21:48.113 に答える