2012-07-13 63 views
5

我具有以下布置:layout_height =“FILL_PARENT”中的RelativeLayout不起作用

<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> 

我希望有具有固定的宽度和高度相等的布局第左垂直线(根布局内第一视图)父母的身高。但是,如果我设置layout_height =“fill_parent”它没有帮助。高度是0.如果我设置高度例如40dip,它将是40下降。但我需要完全fill_parent属性。

+0

其实你想做什么? – AkashG 2012-07-13 08:30:18

+0

您可以发布您想要实现的绘图吗? – 2012-07-13 08:30:32

+0

试试这个,为你的View使用android:layout_alignParentLeft =“true”,然后相对于它设置task_item_startstop_button。 GI输入ID查看 – Shubhayu 2012-07-13 08:30:52

回答

0

这是否解决您的问题?只需用自己的

<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

你给保证金交给家长相对布局更换相关要素,这就是为什么每当你添加任何东西它总是给保证金您的小部件。 从你父母的相对布局中删除android:layout_margin =“10dip”,然后你得到了fil父母中的行。

+0

不工作,你实际上说这里。 – 2016-01-21 16:23:33