2013-05-15 78 views
0

我有这个问题,我需要把TextView的(绿色)内下方的RelativeLayout(黑色),但ImageView的(橙色)的RelativeLayout(蓝色)保持重叠如何将TextView放置在另一个RelativeLayout的RelativeLayout中?

enter image description here

这里的传说:

  • RelativeLayout的(黑色)ID/image_view_container
  • ImageView的(褐色)
  • RelativeLayout的(蓝色)
  • ImageView的(橙色)ID/profileImage
  • 的TextView(绿色)

我想:

android:layout_toRightOf="@id/profileImage" 
android:layout_below="@id/image_view_container" 

,但它不工作,可能是因为image_view_container是从另一个RelativeLayout的。

我需要帮助,谢谢!

编辑:

<RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/image_view_container" > 
       <ImageView 
        android:id="@+id/mainImage" 
        android:layout_width="fill_parent" 
        android:layout_height="210dp" 
        android:background="#ffffff" 
        /> 
    </RelativeLayout> 
<RelativeLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="-30dp" 
      android:gravity="bottom" 
      android:orientation="horizontal" > 
      <ImageView 
       android:id="@+id/profileImage" 
       android:layout_width="50dp" 
       android:layout_height="50dp" 
       android:layout_marginLeft="20dp" 
       android:layout_weight="0" 
       android:layout_alignParentLeft="true" 
       android:layout_alignParentTop="true" 
       android:scaleType="centerCrop" 
       /> 

      <TextView 
       android:id="@+id/name" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="10dp" 
       android:layout_below="@id/image_view_container" 
       android:layout_toRightOf="@id/profileImage" 
       android:layout_weight="1" 
       android:text="6363" 
       android:textColor="@color/A" 
       android:textSize="20sp" 
       android:textStyle="bold" 
       android:translationY="5dp" /> 
     </RelativeLayout> 
+0

后完整的XML请,好像你的蓝相对布局容器不是道具呃 –

+0

你怎么包括_the other_ layout? – ozbek

+0

请发布您的整个XML文件... – Shrikant

回答

0

尝试在你的image_view_container

android:layout_alignParentBottom="true" 
android:layout_alignParentLeft="true" 
0

以下试试这个

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<RelativeLayout 
    android:id="@+id/image_view_container" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="#ff00ff" > 

    <ImageView 
     android:id="@+id/mainImage" 
     android:layout_width="fill_parent" 
     android:layout_height="310dp" 
     android:layout_margin="20dp" 
     android:background="#ffff00" /> 
</RelativeLayout> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/image_view_container" 
    android:layout_alignParentBottom="true" 
    android:orientation="horizontal" > 

    <ImageView 
     android:id="@+id/profileImage" 
     android:layout_width="50dp" 
     android:layout_height="50dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="20dp" 
     android:layout_weight="0" 
     android:background="#ff1234" 
     android:scaleType="centerCrop" /> 

    <TextView 
     android:id="@+id/name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:layout_below="@id/profileImage" 
     android:layout_toRightOf="@id/profileImage" 
     android:layout_weight="1" 
     android:text="6363" 
     android:background="#ff0034" 
     android:textSize="20sp" 
     android:textStyle="bold" /> 
</RelativeLayout> 

相关问题