2011-02-10 3 views
1

У меня есть RelativeLayout, у которого есть LinearLayout как дочерний элемент, содержащий TextViews.RelativeLayout: нельзя использовать layout_below со ссылкой на дочерний элемент LinearLayout?

Я хотел бы разместить ImageViews в правой части TextViews с layout_alignRight = "@ id/userdetail_tv_special", но так или иначе это не работает.

Не удается ли «связать» ребенка RelativeLayout с дочерним элементом LinearLayout? Любые идеи, как я мог достичь этого, не создавая другого RelativeLayout для каждой кнопки?

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
    <LinearLayout 
     android:id="@+id/userdetail_lin_btncontainer" 
     android:layout_width="fill_parent" 
     android:layout_height="50dp" 
     android:layout_below="@id/userdetail_lin_divider" 
     android:padding="6dp" > 
     <TextView 
      android:id="@+id/userdetail_tv_special" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_weight="1" 
      android:text="Special" 
      android:background="#cccccc" /> 
     <!-- here are more TextViews like this one --> 
    </LinearLayout> 
    <ImageView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignRight="@id/userdetail_tv_special" 
     android:src="@drawable/ic_detail_special" /> 
     <!-- much more views and stuff --> 
</RelativeLayout> 

ответ

3

Казалось бы логичным, что вы не можете указать на «layour» глубже: вы можете раскладку детей в RelativeLayout против друг-друга, но вы LinearLayout полный вид, что вы можете использовать в качестве Справка.

Если вы хотите иметь возможность размещать представления относительно текстового вида, поместите их в качестве прямых дочерних элементов релятивирования. Я не понимаю, почему вам, кстати, понадобится LinearLayout.

+1

LinearLayout имеет 5 TextViews с layout_width = fill_parent и layout_weigth = 1 для растяжения их, чтобы заполнить всю ширину экрана ... есть еще одна возможность сделать это? – qedejavu

0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:id="@+id/imgview" 
    android:src="@drawable/ic_detail_special" /> 

<LinearLayout 
    android:id="@+id/userdetail_lin_btncontainer" 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:layout_below="@id/userdetail_lin_divider" 
    android:layout_alignLeft="@id/imgview" 
    android:padding="6dp" > 
    <TextView 
     android:id="@+id/userdetail_tv_special" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:layout_weight="1" 
     android:text="Special" 
     android:background="#cccccc" /> 
    <!-- here are more TextViews like this one --> 
</LinearLayout> 

     <!-- much more views and stuff --> 

Смежные вопросы