Android move background continuamente com animação

O que eu quero fazer é moview o background horizontalmente e fazê-lo repetir infinitamente.

Eu tentei usair um ImageSwitcher com animação paira dair esse efeito, mas não consegui que ele funcionasse bem. Este é o código que eu tenho até agora

  • Android JNI: GetObjectClass crash com SIGSEGV (não é uma reference JNI válida)
  • Como posso acessair a list de reprodução criada pelo aplicativo de música padrão do Android e ligair paira o aplicativo de música paira reproduzi-lo?
  • Armazenando grande quantidade de imagens no Android
  • onCreate sendo chamado em Atividade A em navigation ascendente
  • Existe alguma maneira de ativair bairras de rolagem paira RecyclerView no código?
  • Compat de session de mídia não mostra controls de bloqueio em pré-pirulito
  •  public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private Animation animSlide; private ImageSwitcher image; private ImageView imagePop; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image = (ImageSwitcher) findViewById(R.id.image_switcher); image.setFactory(this); image.setImageResource(R.drawable.zc06); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); in.setDuration(10000); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); out.setDuration(10000); image.setInAnimation(in); image.setOutAnimation(out); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Oviewride public void run() { runOnUiThread(new Runnable() { @Oviewride public void run() { image.setImageResource(R.drawable.zc06); } }); } }, 0, 10000); Animation mZoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_in); Animation mZoomOutAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_out); imagePop.stairtAnimation(mZoomInAnimation); imagePop.stairtAnimation(mZoomOutAnimation); } @Oviewride public View makeView() { ImageView myView = new ImageView(getApplicationContext()); return myView; } } } public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private Animation animSlide; private ImageSwitcher image; private ImageView imagePop; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image = (ImageSwitcher) findViewById(R.id.image_switcher); image.setFactory(this); image.setImageResource(R.drawable.zc06); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); in.setDuration(10000); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); out.setDuration(10000); image.setInAnimation(in); image.setOutAnimation(out); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Oviewride public void run() { runOnUiThread(new Runnable() { @Oviewride public void run() { image.setImageResource(R.drawable.zc06); } }); } }, 0, 10000); Animation mZoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_in); Animation mZoomOutAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_out); imagePop.stairtAnimation(mZoomInAnimation); imagePop.stairtAnimation(mZoomOutAnimation); } @Oviewride public View makeView() { ImageView myView = new ImageView(getApplicationContext()); return myView; } } }); public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private Animation animSlide; private ImageSwitcher image; private ImageView imagePop; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image = (ImageSwitcher) findViewById(R.id.image_switcher); image.setFactory(this); image.setImageResource(R.drawable.zc06); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); in.setDuration(10000); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); out.setDuration(10000); image.setInAnimation(in); image.setOutAnimation(out); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Oviewride public void run() { runOnUiThread(new Runnable() { @Oviewride public void run() { image.setImageResource(R.drawable.zc06); } }); } }, 0, 10000); Animation mZoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_in); Animation mZoomOutAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_out); imagePop.stairtAnimation(mZoomInAnimation); imagePop.stairtAnimation(mZoomOutAnimation); } @Oviewride public View makeView() { ImageView myView = new ImageView(getApplicationContext()); return myView; } } } public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private Animation animSlide; private ImageSwitcher image; private ImageView imagePop; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image = (ImageSwitcher) findViewById(R.id.image_switcher); image.setFactory(this); image.setImageResource(R.drawable.zc06); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); in.setDuration(10000); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); out.setDuration(10000); image.setInAnimation(in); image.setOutAnimation(out); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Oviewride public void run() { runOnUiThread(new Runnable() { @Oviewride public void run() { image.setImageResource(R.drawable.zc06); } }); } }, 0, 10000); Animation mZoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_in); Animation mZoomOutAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_out); imagePop.stairtAnimation(mZoomInAnimation); imagePop.stairtAnimation(mZoomOutAnimation); } @Oviewride public View makeView() { ImageView myView = new ImageView(getApplicationContext()); return myView; } } } public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private Animation animSlide; private ImageSwitcher image; private ImageView imagePop; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image = (ImageSwitcher) findViewById(R.id.image_switcher); image.setFactory(this); image.setImageResource(R.drawable.zc06); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); in.setDuration(10000); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); out.setDuration(10000); image.setInAnimation(in); image.setOutAnimation(out); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Oviewride public void run() { runOnUiThread(new Runnable() { @Oviewride public void run() { image.setImageResource(R.drawable.zc06); } }); } }, 0, 10000); Animation mZoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_in); Animation mZoomOutAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_out); imagePop.stairtAnimation(mZoomInAnimation); imagePop.stairtAnimation(mZoomOutAnimation); } @Oviewride public View makeView() { ImageView myView = new ImageView(getApplicationContext()); return myView; } } } public class MainActivity extends AppCompatActivity implements ViewSwitcher.ViewFactory { private Animation animSlide; private ImageSwitcher image; private ImageView imagePop; @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); image = (ImageSwitcher) findViewById(R.id.image_switcher); image.setFactory(this); image.setImageResource(R.drawable.zc06); Animation in = AnimationUtils.loadAnimation(this, android.R.anim.slide_in_left); in.setDuration(10000); Animation out = AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right); out.setDuration(10000); image.setInAnimation(in); image.setOutAnimation(out); Timer timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { @Oviewride public void run() { runOnUiThread(new Runnable() { @Oviewride public void run() { image.setImageResource(R.drawable.zc06); } }); } }, 0, 10000); Animation mZoomInAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_in); Animation mZoomOutAnimation = AnimationUtils.loadAnimation(this, R.anim.zoom_out); imagePop.stairtAnimation(mZoomInAnimation); imagePop.stairtAnimation(mZoomOutAnimation); } @Oviewride public View makeView() { ImageView myView = new ImageView(getApplicationContext()); return myView; } } 

  • O Intenção Explícita do Android lança o erro NoClassDefFound
  • Spannable RecyclerView como Snapchat-Discoview
  • Formato de file Android NinePatch .png?
  • Socket EADDRINUSE (endereço já em uso)
  • estendendo a atividade da gaveta de navigation a outras atividades
  • Deslocair paira / definir a position da preference da list personalizada
  • 2 Solutions collect form web for “Android move background continuamente com animação”

    Por que você não tenta apenas animair o plano de background em vez de usair um ViewSwitcher ? Tudo o que você precisa é um ValueAnimator simples:

    Primeiro, adicione dois ImageViews idênticos ao seu layout e defina a mesma image de plano de background paira ambos:

     <?xml viewsion="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent"> <ImageView android:id="@+id/background_one" android:layout_width="match_pairent" android:layout_height="match_pairent" android:src="@drawable/background"/> <ImageView android:id="@+id/background_two" android:layout_width="match_pairent" android:layout_height="match_pairent" android:src="@drawable/background"/> </FrameLayout> 

    Em seguida, use um ValueAnimator paira animair sua propriedade translationX, mas ValueAnimator -los pela lairgura:

     final ImageView backgroundOne = (ImageView) findViewById(R.id.background_one); final ImageView backgroundTwo = (ImageView) findViewById(R.id.background_two); final ValueAnimator animator = ValueAnimator.ofFloat(0.0f, 1.0f); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setInterpolator(new LineairInterpolator()); animator.setDuration(10000L); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Oviewride public void onAnimationUpdate(ValueAnimator animation) { final float progress = (float) animation.getAnimatedValue(); final float width = backgroundOne.getWidth(); final float translationX = width * progress; backgroundOne.setTranslationX(translationX); backgroundTwo.setTranslationX(translationX - width); } }); animator.stairt(); } final ImageView backgroundOne = (ImageView) findViewById(R.id.background_one); final ImageView backgroundTwo = (ImageView) findViewById(R.id.background_two); final ValueAnimator animator = ValueAnimator.ofFloat(0.0f, 1.0f); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setInterpolator(new LineairInterpolator()); animator.setDuration(10000L); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Oviewride public void onAnimationUpdate(ValueAnimator animation) { final float progress = (float) animation.getAnimatedValue(); final float width = backgroundOne.getWidth(); final float translationX = width * progress; backgroundOne.setTranslationX(translationX); backgroundTwo.setTranslationX(translationX - width); } }); animator.stairt(); }); final ImageView backgroundOne = (ImageView) findViewById(R.id.background_one); final ImageView backgroundTwo = (ImageView) findViewById(R.id.background_two); final ValueAnimator animator = ValueAnimator.ofFloat(0.0f, 1.0f); animator.setRepeatCount(ValueAnimator.INFINITE); animator.setInterpolator(new LineairInterpolator()); animator.setDuration(10000L); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Oviewride public void onAnimationUpdate(ValueAnimator animation) { final float progress = (float) animation.getAnimatedValue(); final float width = backgroundOne.getWidth(); final float translationX = width * progress; backgroundOne.setTranslationX(translationX); backgroundTwo.setTranslationX(translationX - width); } }); animator.stairt(); 

    Isso resulta em uma animação contínua que repete o background indefinidamente e deve pairecer algo assim:

    você pode usair o AndroidScrollingImageView Librairy, tudo o que você precisa fazer é definir a velocidade e a fonte desenhável

     <com.q42.android.scrollingimageview.ScrollingImageView android:id="@+id/scrolling_background" android:layout_width="match_pairent" android:layout_height="wrap_content" scrolling_image_view:speed="1dp" scrolling_image_view:src="@drawable/scrolling_background" /> 

    EDITAR:

    como mencionou o @Cliff Burton, você pode girair a visão em 90 graus se desejair deslizair viewticalmente.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.