【问题标题】:not a sibling in the same RelativeLayout?不是同一个RelativeLayout中的兄弟姐妹?
【发布时间】:2017-10-17 12:57:35
【问题描述】:

您好,我开始使用 Android 开发。我只是在用 Android Studio 修改一个开源示例。

我只修改了 string.xml 和一些 .png 文件。在 Android 模拟器中它运行完美,但是当我尝试生成签名的 Apk 文件时,我收到两个描述相似的错误。

这是其中之一(该行标有 *):

错误:(33) 错误:@id/linear_adview 不是同级的同级 相对布局 [非同级]

【问题讨论】:

  • 请分享.xml文件
  • 请提供您的 xml 布局
  • 首先你必须从 This android:layout_above="@+id/linear_adview" To android:layout_above="@id/linear_adview" 中删除“+”
  • 没有给出有用的信息。提供完整的 xml 文件。

标签: java android android-studio kotlin


【解决方案1】:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/res-auto"
    android:id="@+id/rl_content_root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background">
 <LinearLayout`enter code here`
        android:id="@+id/linear_adview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <com.google.android.gms.ads.AdView
            android:id="@+id/ad_view_editimg"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            ads:adSize="BANNER"

 <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/sticker_recycler_view"
            android:layout_below="@id/linear_adview">

            <FrameLayout
                android:id="@+id/sticker_framelayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/linear_adview">


                <ImageView
                    android:id="@+id/pic_edit_imageview"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:padding="5dp"
                    android:scaleType="centerCrop"
                    android:src="@drawable/background"

                    />

                <include
                    layout="@layout/text_layout"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent" />

            </FrameLayout>


        </RelativeLayout>
    </LinearLayout>
    <android.support.v7.widget.RecyclerView
            android:id="@+id/sticker_recycler_view"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="5dp"
            android:visibility="visible"
            android:layout_above="@+id/linearLayout" />

    <LinearLayout
        android:id="@+id/linearLayout"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="@color/colorPrimary"
        android:orientation="horizontal">

        <TextView
            android:id="@+id/smoke_tv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:clickable="true"
            android:background="@color/black"
            android:gravity="center"
            android:text="@string/smoke"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/text_tv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:clickable="true"
            android:gravity="center"
            android:text="@string/text"
            android:textColor="@color/white"
            android:textSize="18sp" />

        <TextView
            android:id="@+id/share_tv"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center_vertical"
            android:layout_weight="1"
            android:gravity="center"
            android:clickable="true"
            android:text="@string/share"
            android:textColor="@color/white"
            android:textSize="18sp" />
    </LinearLayout>
</RelativeLayout>`
`

【讨论】:

    【解决方案2】:

    带有android:id="@+id/sticker_framelayout" 的FrameLayout 不是带有android:id="@+id/linear_adview" 的LinearLayout 的直接兄弟,这就是为什么您不能在其中使用android:layout_below="@id/linear_adview" 的原因。其实你可以将 RelativeLayout 和 FrameLayout 合并到一个视图中:

    <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_above="@+id/sticker_recycler_view"
            android:layout_below="@id/linear_adview">
    
            <FrameLayout
                android:id="@+id/sticker_framelayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_below="@id/linear_adview">
    
    (...)
    
            </FrameLayout>
    

    <FrameLayout
                android:id="@+id/sticker_framelayout"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/sticker_recycler_view"
                android:layout_below="@id/linear_adview">
    
    (...)
    
    </FrameLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-07-12
      • 1970-01-01
      • 2019-05-06
      • 2012-07-23
      • 1970-01-01
      • 2011-01-09
      • 1970-01-01
      相关资源
      最近更新 更多