2013-05-15 79 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> 

相關問題