eclipse 不是同一个RelativeLayout中的兄弟

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25527973/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 21:55:15  来源:igfitidea点击:

is not a sibling in the same RelativeLayout

androideclipsesiblings

提问by javier_pelaez

Hello I am starting with Android developing. I am just modifying with ECLIPSE an open source example. I have only modified strings.xml and some .png files. In the Android simulator it works perfect but when I try to generate the signed apk file I receive two errors with similar description. This is one of them (the line is marking with *):

您好,我是从 Android 开发开始的。我只是用 ECLIPSE 修改一个开源示例。我只修改了 strings.xml 和一些 .png 文件。在 Android 模拟器中,它运行良好,但是当我尝试生成签名的 apk 文件时,我收到两个具有类似描述的错误。这是其中之一(该行标有 *):

Description @+id/about_us_desc_webview is not a sibling in the same RelativeLayout cc3x_about_us.xml

说明@+id/about_us_desc_webview 不是同一个RelativeLayout cc3x_about_us.xml 中的兄弟

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
style="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey_background"
android:orientation="vertical" >

<include
    android:id="@+id/cc3x_about_header_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    layout="@layout/cc3x_headerlayout" />

<TextView
    android:id="@+id/about_us_textview"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/cc3x_about_header_view"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="@dimen/about_title_label_top_margin"
    android:text="@string/about_us_label"
    android:textColor="@color/grey_text_color"
    android:textSize="@dimen/extra_large_text_size"
    android:textStyle="bold" />

<View
    android:id="@+id/view1"
    android:layout_width="fill_parent"
    android:layout_height="@dimen/min_divider_height"
    android:layout_below="@+id/about_us_textview"
    android:layout_marginLeft="@dimen/about_title_label_side_margin"
    android:layout_marginRight="@dimen/about_title_label_side_margin"
    android:background="@drawable/about_page_divline" />

<WebView
    android:id="@+id/about_us_desc_webview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/view1"
    android:layout_marginLeft="@dimen/about_title_label_side_margin"
    android:layout_marginRight="@dimen/about_title_label_side_margin"
    android:layout_marginTop="@dimen/min_margin_cutoff" />

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/about_us_desc_webview" >

    <TextView
        android:id="@+id/about_screen_contact_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
      * android:layout_below="@+id/about_us_desc_webview"
        android:layout_centerHorizontal="true"
        android:text="@string/contact_label"
        android:textColor="@color/grey_text_color"
        android:textSize="25dip"
        android:textStyle="bold" />

    <View
        android:id="@+id/divider_bottom"
        android:layout_width="match_parent"
        android:layout_height="@dimen/min_divider_height"
        android:layout_below="@+id/about_screen_contact_label"
        android:layout_marginLeft="@dimen/about_title_label_side_margin"
        android:layout_marginRight="@dimen/about_title_label_side_margin"
        android:background="@drawable/about_page_divline" />

    <TextView
        android:id="@+id/about_xcube_link"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/divider_bottom"
        android:layout_margin="@dimen/max_margin_size"
        android:autoLink="web"
        android:text="@string/xcube_url"
        android:textColor="@color/blue_text_color"
        android:textColorLink="@color/blue_text_color"
        android:textSize="10dip" />

    <TextView
        android:id="@+id/about_xcube_contact_email"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_below="@+id/divider_bottom"
        android:layout_margin="@dimen/max_margin_size"
        android:autoLink="email"
        android:text="@string/xcube_contact_email"
        android:textSize="@dimen/small_text_height" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/about_xcube_link"
        android:layout_centerHorizontal="true"
        android:gravity="center"
        android:text="@string/about_xcube_address"
        android:textColor="@color/grey_text_color"
        android:textSize="@dimen/small_text_height" />
</RelativeLayout>

</RelativeLayout>

Any help will be apreciated. Thank you very much!!

任何帮助将不胜感激。非常感谢!!

采纳答案by IntelliJ Amiya

android:layout_below

安卓:layout_below

Positions the top edge of this view below the given anchor view ID .

将此视图的顶部边缘定位在给定的锚视图 ID 下方。

When Arise

当出现

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:id="@+id/rl_rootHeader"


>


<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/rl_Header"
    android:layout_below="@+id/rl_rootHeader" // Arise ,In here RelativeLayout is Parent .

    >

    //
</RelativeLayout>

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:fillViewport="true"
    android:id="@+id/scrollRoot"
    android:background="@color/colorWhite"


    >

</ScrollView>

Right Way

正确的方法

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@color/colorWhite"
android:id="@+id/rl_rootHeader"


>


<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/rl_Header"


    >

    //
</RelativeLayout>

<ScrollView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:fillViewport="true"
    android:id="@+id/scrollRoot"
    android:background="@color/colorWhite"
    android:layout_below="@+id/rl_rootHeader"  // Call Here .This section is Child


    >

</ScrollView>

回答by Faruk Yaz?c?

The line

线

android:layout_below="@+id/about_us_desc_webview"

in your TextView is redundant. Since the RelativeLayout already has that attribute, it is useless. You can just erase that line and nothing should change.

在您的 TextView 中是多余的。由于RelativeLayout 已经具有该属性,所以它是无用的。你可以擦除那条线,什么都不应该改变。

And the reason it generates error is that, you can apply features such as below, above.. etc with an element in the same layout. Here "about_us_desc_webview" is out of the RelativeLayout and you cannot position something inside a RelativeLayout with something outside a RelativeLayout.

它产生错误的原因是,您可以在同一布局中对元素应用诸如下方、上方等功能。这里的“about_us_desc_webview”不在RelativeLayout 中,您不能在RelativeLayout 内部使用RelativeLayout 之外的内容定位某些内容。

回答by Gaurav Ghongde

Just remove the lines which are causing error from layout .xml file

只需从布局 .xml 文件中删除导致错误的行

Try refreshing the layout

尝试刷新布局

Your layout will probably change. You can now reset it properly.

您的布局可能会改变。您现在可以正确重置它。

回答by Ram G.

If you go to Properties Panel you will see layout:alignComponent has some alignment shown as "Not Found". Just clear it out. In the above example Properties window -> textview -> layout:alignComponent check all alignment values.

如果您转到“属性”面板,您将看到 layout:alignComponent 有一些显示为“未找到”的对齐方式。把它清除掉就行了。在上面的示例中,属性窗口 -> textview -> layout:alignComponent 检查所有对齐值。