eclipse 考虑添加 android:paddingStart="25dp" 以更好地支持从右到左的布局错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25132076/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Consider adding android:paddingStart="25dp" to better support right-to-left layouts Error
提问by Anand.B
I recently downloaded a new ADT
. Every time after saving my projects ,it shows the following XML
error. But the same goes away when I clean it. Is there a permanent solution for the same.
我最近下载了一个新的ADT
. 每次保存我的项目后,它都会显示以下XML
错误。但是当我清洁它时,同样的情况就会消失。是否有相同的永久解决方案。
Thanks in advance.
提前致谢。
<TextView
android:id="@+id/selectquantityprompt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="2dip"
android:layout_marginRight="50dip"
android:layout_marginTop="2dip"
android:text="Select Quantity"
android:textSize="20sp"
android:textColor="#33b5e5"
android:paddingLeft="25dp" //error at this line
android:paddingTop="5dp"
android:paddingBottom="5dp"
/>
Multiple annotations found at this line:
在这一行找到多个注释:
- Consider adding android:paddingStart="25dp" to better support right-to-left layouts
- When you define %1$s you should probably also define %2$s for right-to-left
回答by Yashdeep Patel
android:paddingStart is newly introduced tag in android 4.2 onwards.
android:paddingStart 是 android 4.2 以后新引入的标签。
Now RTL means right-to-left layouts which are used in RTL languages like arabic.
现在 RTL 是指从右到左的布局,在 RTL 语言(如阿拉伯语)中使用。
So while developing layout you can add same value to paddingStart as padding left. So that when android render RTL layout it will consider paddingStart.
因此,在开发布局时,您可以向 paddingStart 添加与 padding left 相同的值。这样当 android 渲染 RTL 布局时它会考虑 paddingStart。
- If you are targeting your app to Android 4.2 (the app's targetSdkVersion or minSdkVersion is 17 or higher), then you should use “start” and “end” instead of “left” and “right”. For example, android:paddingLeft should become android:paddingStart.
- If you want your app to work with versions earlier than Android 4.2 (the app's targetSdkVersion or minSdkVersion is 16 or less), then you should add “start” and end” in addition to “left” and “right”. For example, you'd use both android:paddingLeft and android:paddingStart.
- 如果您的应用面向 Android 4.2(应用的 targetSdkVersion 或 minSdkVersion 为 17 或更高),那么您应该使用“start”和“end”而不是“left”和“right”。例如,android:paddingLeft 应该变成 android:paddingStart。
- 如果您希望您的应用程序使用早于 Android 4.2 的版本(应用程序的 targetSdkVersion 或 minSdkVersion 为 16 或更低),那么除了“左”和“右”之外,您还应该添加“开始”和“结束”。例如,您将同时使用 android:paddingLeft 和 android:paddingStart。
Ref Links: RTL Layout Support
参考链接:RTL 布局支持
回答by Frederico Silva
If you want to change the severity of that error go to "Lint Error Checking" at Preferences and change "RtlSymmetry" to "Warning" instead "Error".
如果您想更改该错误的严重性,请转到首选项中的“Lint 错误检查”并将“RtlSymmetry”更改为“警告”而不是“错误”。
回答by sree
Just add android:paddingRight="0dp" along with android:paddingLeft="25dp", error will disappear.
只需添加 android:paddingRight="0dp" 和 android:paddingLeft="25dp",错误就会消失。
回答by myfknoll
Answer from sreenusolved my issue. But if you target higher APIs you should also add paddingEnd, as in the following example:
sreenu 的回答解决了我的问题。但是如果你的目标是更高的 API,你还应该添加 paddingEnd,如下例所示:
android:paddingLeft="25dp"
android:paddingStart="25dp"
android:paddingRight="0dp"
android:paddingEnd="0dp"