2012-07-13 5 views
5

動作しない:layout_height RelativeLayoutに=「fill_parentは、」私はレイアウト以下た

Iは、固定幅と等しい高さとレイアウトの目左側の縦線(ルートレイアウト内の最初のビュー)を持ちたい
<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

+0

達成したい図面を投稿できますか? –

+0

これを試して、android:layout_alignParentLeft = "true"を使用してViewに設定し、それに対してtask_item_startstop_buttonを設定してください。 View – Shubhayu

答えて

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

はあなたが実際にここで言ったようには機能しません。 –

関連する問題