Android Studio-避免不同API的布局警告

Android Studio-避免不同API的布局警告,android,android-layout,android-studio,Android,Android Layout,Android Studio,我在res/layout中有这个 <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBaseline="@+id/txt" android:layout_alignBottom="@+id/txt" android:layout_to

我在res/layout中有这个

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/txt"
    android:layout_alignBottom="@+id/txt"
    android:layout_toRightOf="@+id/txt"
    android:text="@string/..."
    android:layout_marginLeft="3dp"
    android:textAppearance="?android:attr/textAppearanceSmall" />

我得到警告,layout\u-toRightOf应该是layout\u-toEndOf,layout\u-marginLeft应该是layout\u-marginart,以更好地支持从右到左的布局


所以我做了两个布局,把另一个放在布局-v17中,并改变了它想要的。虽然layout-v17现在还可以,但原始布局文件上的警告仍然存在,我如何让它知道我已经处理了这些警告?

这些警告来自Lint,它是SDK中实现的一个工具,正在检查整个项目以查找潜在的bug。 退房

下面是一组Lint检查,只要您定义了
xmlns:tools=”,就可以使用
tools:ignore=
attributite忽略每个Lint检查http://schemas.android.com/tools“
在根视图中。 当然,只有在需要时才应该使用此功能,因为lint检查在防止bug方面很有用

与您的问题相关的属性是
RtlHardcoded
,在任何情况下都不会让人讨厌

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="RtlHardcoded" >

    <TextView
        android:text="@string/text"
        android:layout_toRightOf="@+id/txt" />
</RelativeLayout>

注意,您还可以从IDE选项中为整个项目禁用特定的
Lint
检查,但我不会这么做。(在Android Studio中,项目设置->检查)

编辑: 还要注意,这并不是忽略一个真正的问题。我建议你这么做是因为我想象你只是被一个关于你已经处理过的情况的警告“打扰”了。在这些情况下,
tools:ignore
可以用来告诉Lint“好的,我知道这个问题,而且我已经解决了”(大多数情况下,Lint很聪明,可以自己注意到)


关于从右到左的布局,处理它们的最佳方法是放置两个左(右)/开始(结束)属性。在API>17上,后者将具有优先权。

这些警告来自Lint,一个在SDK中实现的工具,它正在检查整个项目以查找潜在的bug。 退房

下面是一组Lint检查,只要您定义了
xmlns:tools=”,就可以使用
tools:ignore=
attributite忽略每个Lint检查http://schemas.android.com/tools“
在根视图中。 当然,只有在需要时才应该使用此功能,因为lint检查在防止bug方面很有用

与您的问题相关的属性是
RtlHardcoded
,在任何情况下都不会让人讨厌

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="RtlHardcoded" >

    <TextView
        android:text="@string/text"
        android:layout_toRightOf="@+id/txt" />
</RelativeLayout>

注意,您还可以从IDE选项中为整个项目禁用特定的
Lint
检查,但我不会这么做。(在Android Studio中,项目设置->检查)

编辑: 还要注意,这并不是忽略一个真正的问题。我建议你这么做是因为我想象你只是被一个关于你已经处理过的情况的警告“打扰”了。在这些情况下,
tools:ignore
可以用来告诉Lint“好的,我知道这个问题,而且我已经解决了”(大多数情况下,Lint很聪明,可以自己注意到)


关于从右到左的布局,处理它们的最佳方法是放置两个左(右)/开始(结束)属性。在API>17上,后者将具有优先权。

这些警告来自Lint,一个在SDK中实现的工具,它正在检查整个项目以查找潜在的bug。 退房

下面是一组Lint检查,只要您定义了
xmlns:tools=”,就可以使用
tools:ignore=
attributite忽略每个Lint检查http://schemas.android.com/tools“
在根视图中。 当然,只有在需要时才应该使用此功能,因为lint检查在防止bug方面很有用

与您的问题相关的属性是
RtlHardcoded
,在任何情况下都不会让人讨厌

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="RtlHardcoded" >

    <TextView
        android:text="@string/text"
        android:layout_toRightOf="@+id/txt" />
</RelativeLayout>

注意,您还可以从IDE选项中为整个项目禁用特定的
Lint
检查,但我不会这么做。(在Android Studio中,项目设置->检查)

编辑: 还要注意,这并不是忽略一个真正的问题。我建议你这么做是因为我想象你只是被一个关于你已经处理过的情况的警告“打扰”了。在这些情况下,
tools:ignore
可以用来告诉Lint“好的,我知道这个问题,而且我已经解决了”(大多数情况下,Lint很聪明,可以自己注意到)


关于从右到左的布局,处理它们的最佳方法是放置两个左(右)/开始(结束)属性。在API>17上,后者将具有优先权。

这些警告来自Lint,一个在SDK中实现的工具,它正在检查整个项目以查找潜在的bug。 退房

下面是一组Lint检查,只要您定义了
xmlns:tools=”,就可以使用
tools:ignore=
attributite忽略每个Lint检查http://schemas.android.com/tools“
在根视图中。 当然,只有在需要时才应该使用此功能,因为lint检查在防止bug方面很有用

与您的问题相关的属性是
RtlHardcoded
,在任何情况下都不会让人讨厌

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    tools:ignore="RtlHardcoded" >

    <TextView
        android:text="@string/text"
        android:layout_toRightOf="@+id/txt" />
</RelativeLayout>

注意,您还可以从IDE选项中为整个项目禁用特定的
Lint
检查,但我不会这么做。(在Android Studio中,项目设置->检查)

编辑: 还要注意,这并不是忽略一个真正的问题。我建议你这么做是因为我想象你只是被一个关于你已经处理过的情况的警告“打扰”了。在这些情况下,
tools:ignore
可以用来告诉Lint“好的,我知道这个问题,而且我已经解决了”(大多数情况下,Lint很聪明,可以自己注意到)

关于从右到左的布局,处理它们的最佳方法是放置两个左(右)/开始(结束)属性。在API>17上,后者将具有优先级。

放置两次 布局图 和布局在同一文本中