Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is LinearLayoutCompat in appCompat v7?

In the support library appCompat v7 of the Android platform, there is a android.support.v7.widget.LinearLayoutCompat class.

Does someone know why this class exist? The original LinearLayout class exist since API level 1 so I don't understand why there is a compat version.

like image 849
ol_v_er Avatar asked Oct 22 '14 17:10

ol_v_er


People also ask

What is LinearLayoutCompat?

LinearLayoutCompat was added to support methods which were added in newer API levels on old ones (like dividers). If you compare the methods in LinearLayout and LinearLayoutCompat you can see that the Compat layout has all methods of the LinearLayout without any API level limitation.

What is Linear layout compat in Android?

A Layout that arranges its children in a single column or a single row.


1 Answers

The class LinearLayout exists since API level 1, but some APIs were added after that, for example, setShowDividers introduced on API level 11.

So in this case setShowDividers (and it's parameters) should be invoked using LinearLayoutCompat instead LinearLayout if you are targeting a platform with API level below 11.

like image 53
tato.rodrigo Avatar answered Sep 30 '22 10:09

tato.rodrigo