我想根据布局B中的内容,在布局A的下方,左侧,右侧,顶部,底部对齐一些元素。
所以,我有:
布局A:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/stateview_coinshop"
style="@style/AlertPopup"
android:layout_width="@dimen/PopupWidth"
android:layout_height="@dimen/PopupHeight"
android:layout_gravity="center"
android:clickable="false"
android:gravity="center" >
<include
android:id="@+id/popup_window"
android:layout_width="@dimen/PopupWidth"
android:layout_height="@dimen/PopupHeight"
layout="@layout/layoutB" />
<TextView
android:id="@+id/messageBoxTitle"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignLeft="@id/popup_background"
android:layout_alignRight="@id/popup_background"
android:layout_alignTop="@id/popup_background"
android:layout_centerHorizontal="true"
android:gravity="center"
android:shadowColor="#152E08"
android:shadowDx="-3"
android:shadowDy="3"
android:shadowRadius="2"
android:text="Mytitle"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textStyle="italic|bold" />
</RelativeLayout>
布局B:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_window"
android:layout_width="@dimen/PopupWidth"
android:layout_height="@dimen/PopupHeight"
android:layout_gravity="center"
android:gravity="center" >
<!-- BORDER -->
<ImageView
android:id="@+id/popup_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/backgroundContainer"
android:layout_alignLeft="@id/backgroundContainer"
android:layout_alignRight="@id/backgroundContainer"
android:layout_alignTop="@id/backgroundContainer"
android:layout_marginBottom="@dimen/PopupBorderUpDownMargin"
android:layout_marginLeft="@dimen/PopupBorderSideMargin"
android:layout_marginRight="@dimen/PopupBorderSideMargin"
android:layout_marginTop="@dimen/PopupBorderUpDownMargin"
android:adjustViewBounds="true"
android:background="@drawable/pop_up_main_stroke"
android:cropToPadding="true"
android:scaleType="centerInside" />
<!-- CLOSE BUTTON -->
<Button
android:id="@+id/buttonClose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_gravity="right"
android:layout_marginRight="@dimen/PopupCloseButtonMargin"
android:layout_marginTop="@dimen/PopupCloseButtonMargin"
android:background="@drawable/pop_up_close_button"
android:minHeight="48dp"
android:minWidth="48dp"
android:scaleType="centerInside" />
</RelativeLayout>
问题:布局A从B中找到ID,但它们被忽略了。即使我在布局B(包括一个)中添加它们作为+ id,作为值(id),id,任何东西。这是行不通的。
我该怎么办?
修改 我通过从RelativeLayout修改布局的B根标签来解决这个问题。简单的改变。