What is LinearLayoutCompat in appCompat v7?

ol_v_er picture ol_v_er · Oct 22, 2014 · Viewed 11k times · Source

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.

Answer

tato.rodrigo picture tato.rodrigo · Oct 22, 2014

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.