mohamed mohy mohamed mohy - 21 days ago 5
Android Question

Skipped 181 frames ... Android


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);
}
}

Answer

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