关于paddingStart使用冲突的皮棉消息皮棉、冲突、消息、paddingStart

2023-09-05 01:40:02 作者:男人可以输但绝不能哭.

API 17后/ RTL支持被释放,我增加了以下我的清单

After API 17 / RTL support was released, I added the following to my manifest

android:supportsRtl="true"

这导致皮棉到理所当然地给我这些警告,无论我有以下属性来/右在我的观点:

which caused Lint to rightfully give me these warnings wherever I had paddingLeft/Right in my views:

  

考虑增加机器人:paddingStart =8DP,以更好地支持从右到左的布局

Consider adding android:paddingStart="8dp" to better support right-to-left layouts

考虑增加机器人:paddingEnd =8DP,以更好地支持从右到左的布局

Consider adding android:paddingEnd="8dp" to better support right-to-left layouts

我这样做是按照本中发现的指导android-developers博文,这意味着我们并不需要创建一个新的布局-V17文件,而是可以只使用两个paddingStart /结束还有以下属性来/属性(左/右被要求继续支持较低的minSdk)。

I did this following the guidance found in this android-developers blogpost, which implied that we did not need to create a new layout-v17 file, but rather could just use both the paddingStart/End as well as the paddingLeft/Right attributes (the Left/Right were required to continue supporting a lower minSdk).

我刚刚从previous Beta版做了更新到Android 1.0演播室,和我注意到一个新的皮棉错误的规定:

I just made the update to Android Studio 1.0 from the previous Beta version, and am noticing a new lint error which states:

  属性paddingStart此处引用可能导致崩溃的年龄超过17 API一些特定的设备(目前最小为7)   

和建议的解决方法是:

在布局-V17改写资源

Override Resource in layout-v17

这是有道理的。但是,创建布局-V17和删除未使用的paddingStart /结束从主要布局文件夹后,原来的lint警告又重新出现,说我应该使用paddingStart /结束。现在看来似乎不明白,我已经overrided布局-V17的文件。

Which makes sense. However, after creating layout-v17 and removing the unused paddingStart/End from the main layout folder, the original Lint warnings have reappeared saying that I should use paddingStart/End. It seems like it does not understand that I have overrided the files in layout-v17.

有谁知道如何解决似乎是相互矛盾的皮棉错误/警告消息?我知道我可以只工具:忽略警告,但我希望有一个正确的解决方案。

Does anyone know how to solve what seems to be conflicting Lint error/warning messages? I know I can just tools:ignore the warning, but I am hoping for a "proper" solution.

修改(15年1月19日):有一个的 Android的问题的,我想像导致被添加到Android Studio中的新皮棉错误。这表明,在某些特定的设备中的崩溃指的是极少数三星片对API16其中paddingStart具有其自己的定义,因此崩溃时,它试图解析8DP。

Edit (1/19/15): There is an android issue that I imagine led to the new lint error being added to Android Studio. This suggests that the "crash on some specific devices" refers to a handful of Samsung tablets on API16 where paddingStart has its own definition and as such crashes when it tries to parse "8dp".

有些人在上面的链接都建议使用的布局,ldrtl文件夹来处理RTL方向,而不是使用paddingStart和paddingEnd。

Some people in the above link have suggested to use the layout-ldrtl folder to handle the rtl direction, rather than using paddingStart and paddingEnd.

我也有一个建议其他地方覆盖LayoutInflator的FACTORY2无论何时你发现用户有一个API16平板电脑,然后手动设置您的所有意见的属性。这肯定会工作,但它似乎非常手动。

I've also had a suggestion elsewhere to override the LayoutInflator's Factory2 whenever you find that the user has a API16 tablet, and then manually set the attributes of all your views. This will certainly work, but it seems extremely "manual".

我遗憾的是没有接触到这些设备的崩溃,所以我无法验证,为什么我还没有发现有人在网上建议干脆把paddingStart在/布局-V17 /文件夹,以下属性来在/布局/?请执行API16三星平板电脑在某种程度上还是继续崩溃,尽管paddingStart仅是present布局-V17?

I unfortunately don't have access to one of these devices that crash, so I can't verify why I have not found anyone online suggesting simply putting paddingStart in /layout-v17/ folder, and paddingLeft in /layout/? Do the API16 Samsung tablets somehow still continue to crash despite paddingStart only being present in layout-v17?

推荐答案

您说得对这个问题的根本原因 - 三星定义预留 paddingStart 或 paddingEnd

You're right about the root cause of the issue - Samsung defined a custom attribute for the id reserved for paddingStart or paddingEnd.

我绕过这个问题的方法是提取padding属性,并把它们放入一个风格。因此,而不是具有不同的布局SDK< 17和SDK> = 17,我有不同的风格为他们(与以下属性来和放大器;右键 paddingStart和放大器;结束值-V17

The way I by-passed this was to extract the padding properties and put them into a style. So instead of having different layouts for SDK<17 and SDK>=17, I have different styles for them (with paddingLeft&Right in values and paddingStart&End in values-v17).

这样,林特将停止抱怨吧。

This way, Lint will stop complaining about it.