Is the XML attribute android:paddingHorizontal
that was introduced in API 26 (Android O
) only available in 26
and above? Is there a support version of it? I require my minSdkVersion
to be much lower than 26.
I’m under the impression that the Android Asset Packaging Tool 2.0 (AAPT2) , that’s been included in Android Studio 3, could possibly help out with this.
From the release AAPT2 release notes:
Version 2.16
aapt2 link ...
Versioning of XML files is more intelligent, using a small set of rules to degrade specific newer attributes to backwards compatible versions of them. Ex: android:paddingHorizontal degrades to android:paddingLeft and android:paddingRight.
But have not idea how to use AAPT2, and I’m not finding much information out there on how to you it, I just see mentioning of it. Is my request even possible?
Any help/answers are greatly appreciated.
Update: Yeah, it doesn’t work on lower SDK versions.
Although paddingHorizontal
, paddingVertical
, layout_marginHorizontal
andlayout_marginVertical
were introduced in API 26 (Android O), they can be used safely when targetting older SDK versions thanks to the desugaring performed by aapt2
(added in v2.16) that converts these to left/right or top/bottom automatically at build time.
Note: sadly they are not supported in styles (nor planned to be) (ref).
paddingHorizontal and paddingVertical is indeed introduced with API 26 (O). See the Android O update note for proof: https://developer.android.com/about/versions/oreo/android-8.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With