API 26(Android O
)引入的XML属性android:paddingHorizontal
是否只在26
及以上版本可用?它有支持版本吗?我要求我的 minSdkVersion
远低于 26。
我的印象是 Android Asset Packaging Tool 2.0 (AAPT2) ,已包含在 Android Studio 3 中,可能有助于解决此问题。
来自发布 AAPT2 发行说明:
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.
但不知道如何使用 AAPT2,而且我没有找到太多关于如何给你的信息,我只是看到有人提到它。我的请求是否可行?
非常感谢任何帮助/回答。
更新:是的,它不适用于较低的 SDK 版本。
最佳答案
尽管 paddingHorizontal
、paddingVertical
、layout_marginHorizontal
和 layout_marginVertical
是在 API 26 (Android O) 中引入的,由于 aapt2
(添加到 v2.16 中)在构建时自动将它们转换为左/右或上/下。 p>
注意:遗憾的是它们在样式中不受支持(也不计划)( ref )。
关于android - 在 API 26 之前的设备上使用 XML 属性 paddingHorizontal?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47238126/