2012-07-13 8 views
5

He siguiente distribución:layout_height = "fill_parent" en RelativeLayout no funciona

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/item_background" 
    android:layout_margin="10dip" 
    android:gravity="center_vertical"> 

    <View 
     android:layout_width="30dip" 
     android:layout_height="fill_parent" 
     android:background="@color/test_color"/> 

    <ImageView 
     android:id="@+id/task_item_startstop_button" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:src="@drawable/start_task" 
     android:layout_centerVertical="true" 
     android:focusable="false" 
     android:background="#0000"/> 

    <View 
     android:id="@+id/task_item_line" 
     android:layout_width="2dp" 
     android:layout_height="40dip" 
     android:layout_margin="5dip" 
     android:background="@color/line_color" 
     android:layout_toRightOf="@id/task_item_startstop_button"/> 

    <TextView 
     android:id="@+id/task_item_title" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textColor="@android:color/black" 
     android:textSize="22sp" 
     android:textStyle="bold" 
     android:layout_toRightOf="@id/task_item_line" /> 

    <TextView 
     android:id="@+id/task_item_status" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/task_item_suspended" 
     android:textSize="18sp" 
     android:textColor="@android:color/black" 
     android:layout_toRightOf="@id/task_item_line" 
     android:layout_below="@id/task_item_title"/> 

    <TextView 
     android:id="@+id/task_item_timer" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="5dip" 
     android:textSize="18sp" 
     android:textColor="@android:color/black" 
     android:layout_toRightOf="@id/task_item_status" 
     android:layout_below="@id/task_item_title"/> 

</RelativeLayout> 

quiero tener línea vertical (primera vista interior diseño raíz) en el th izquierda de diseño con ancho fijo y altura igual altura de los padres Pero si configuro layout_height = "fill_parent" no ayuda. La altura es 0. Si configuro la altura, por ejemplo 40pb, será de 40 dip. Pero necesito exactamente la propiedad fill_parent.

+0

en realidad lo que quieres hacer? – AkashG

+0

¿Puedes publicar un dibujo de lo que quieres lograr? –

+0

Pruebe esto, use android: layout_alignParentLeft = "true" para su Vista y luego configure task_item_startstop_button relativo a esta. Tengo una identificación para ver – Shubhayu

Respuesta

0

¿Esto soluciona su problema? Basta con sustituir los elementos pertinentes con su propio margen

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

     <Button 
      android:layout_height="match_parent" 
      android:layout_width="30dp" 
      android:id="@+id/thebutton" 
      android:text="hello world" 
      /> 

    <AnalogClock 
     android:id="@+id/analogClock1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@+id/thebutton" /> 

</RelativeLayout> 
-1

le han dado a su disposición relativa de Padres, por eso siempre que añada nada que siempre dan margen a sus widgets. Eliminar android: layout_margin = "10dip" de su disposición relativa parental, luego obtiene la línea que viene en fil parent.

+0

no funciona lo que usted dijo aquí. –

Cuestiones relacionadas