Reputation: 369
I want to check which layout is loading fast with the same design like Relative Layout, Linear Layout or Constraint Layout but I can't get any tool or any idea about that so please help me out for my query.
Thanks in Advance.
Upvotes: 1
Views: 759
Reputation: 645
I think this trick may help you.
long time1 = System.currentTimeMillis();
setContentView(R.layout.activity_main);
long time2 = System.currentTimeMillis();
Log.i(TAG, "onCreate: " + (time2 - time1));
My results for empty parent layout:
ConstraintLayout
: 74ms
RelativeLayout
: 54ms
LinearLayout
: 55ms
FrameLayout
: 57ms
Have tested in Huawei Nexus 6P. Maybe these results will be different, when these layouts draw multiply views, but RelativeLayout
is leading for empty layouts.
Upvotes: 1
Reputation: 2780
A single layout can be made in many different ways. It all depends on the requirement, but still, there are some ways through which we can find the performance of layout. There are some inbuilt tools in our Android Studio itself, like sys trace, layout inspector. There are few ways in our developers' option in our device, that option is GPU. You can also find out which method is taking how much time.
For more clarity, I suggest you go through these topics.
Upvotes: 0