2014-01-23 240 views
0

我有兩個不同的視圖,一個在另一個之上。他們之間他們必須適合整個屏幕。 Bottom上的視圖是一個ListView,它可以包含任意數量的元素。標題或頂部視圖是至少最小尺寸120dp和最大300dp的重疊圖像,但調整大小(和裁剪)以適應底部視圖未使用的任何空間。創建可變尺寸標題

我目前的XML無法正常工作。

<RelativeLayout 
    android:id="@+id/left_drawer" 
    android:layout_width="300dp" 
    android:layout_height="match_parent" 
    android:layout_gravity="start" 
    android:background="@color/drawer_background" 
    android:orientation="vertical"> 

    <FrameLayout 
     android:id="@+id/header_image_holder" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:minHeight="120dp" 
     android:visibility="gone" 
     android:focusable="true" 
     android:clickable="true"> 

     <com.android.volley.toolbox.NetworkImageView 
      android:id="@+id/header_image" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:adjustViewBounds= "true" 
      android:maxHeight="300dp" 
      android:scaleType="centerCrop" /> 

     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom"> 

      <TextView 
       android:layout_width="230dp" 
       android:layout_height="wrap_content" 
       android:id="@+id/header_name" /> 

      <LinearLayout 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:orientation="horizontal" 
       android:layout_alignParentRight="true"> 

       <ImageView 
        android:id="@+id/header_name_separator" 
        android:layout_width="6dp" 
        android:layout_height="match_parent" 
        android:layout_gravity="center_vertical" /> 

       <ToggleButton 
        android:id="@+id/header_button" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center_vertical" 
        android:background="@android:drawable/ic_lock_idle_low_battery" 
        android:textOff="" 
        android:textOn="" /> 

      </LinearLayout> 


     </RelativeLayout> 
    </FrameLayout> 

    <ListView 
     android:id="@+id/drawer_list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/event_image_holder" /> 

</RelativeLayout> 
+0

沒有logcat。這是一個沒有發生的視覺神器。 –

回答

0

最後,我不得不手動要求測量錨定的ListView和屏幕大小,並通過應用程序中的幾個點動態調整元素的大小。