0

Skipped 181 frames! The application may be doing too much work on its main thread

that appears when i run the code and click on the activity ... why is that appearing and how to get rid of it? here is my code

public class MainActivity extends AppCompatActivity {
  public void Dropin(View v){
    ImageView Counter = (ImageView)v;
    Counter.setTranslationY(-1000);
    Counter.setImageResource(R.drawable.red);
    Counter.animate().translationYBy(1000f).setDuration(300);

}
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
 }
}
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245

1 Answers1

1

Your code doesn't have any computationally heavy work so far. The only place is Counter.setImageResource(R.drawable.red) call. Maybe, your image is of much bigger size than you need and Android has to resize it. Another reason - use .png() format for resources, because transition has to make lot of calculations for formats such as .jpg and .bmp

Alex Shutov
  • 3,217
  • 2
  • 13
  • 11