2016-09-26 99 views
0

我想創建一個地圖Fragment上面ListView。不幸的是,這個片段幾乎都在屏幕上方。這些觀點對於調整片段大小非常重要。如果smbd能爲我解釋哪部分是不正確的?片段上方的片段

XML:

<RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fitsSystemWindows="true"> 

<MapHidder.SlidingUpPanelLayout 
      android:id="@+id/slidingLayout" 
      android:gravity="bottom" 
      app:shadowHeight="0dp" 
      app:paralaxOffset="@dimen/paralax_offset" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent"> 

      <FrameLayout 
       android:gravity="top" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 

       <fragment xmlns:map="http://schemas.android.com/apk/res-auto" 
        android:id="@+id/map" 
        android:name="com.google.android.gms.maps.SupportMapFragment" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" /> 
      </FrameLayout> 
      <RelativeLayout 
       android:id="@+id/slidingContainer" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent"> 
      <View 
       android:id="@+id/transparentView" 
       android:visibility="gone" 
       android:layout_width="fill_parent" 
       android:layout_height="@dimen/map_height" 
       android:layout_alignParentTop="true" 
      /> 

      <View 
       android:id="@+id/whiteSpaceView" 
       android:visibility="gone" 
       android:background="@android:color/darker_gray" 
       android:layout_marginTop="@dimen/map_height" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent"/> 

      <MapHidder.LockableListView 
       android:id="@+id/museumList" 
       android:cacheColorHint="@android:color/white" 
       android:drawSelectorOnTop="true" 
       android:dividerHeight="@dimen/divider_height" 
       android:divider="@android:color/darker_gray" 
       android:background="@android:color/transparent" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:smoothScrollbar="false" /> 
     </RelativeLayout> 
     </MapHidder.SlidingUpPanelLayout> 
    </RelativeLayout> 

現在香港專業教育學院獲得水木清華這樣enter image description here

更新我試圖改變相對佈局,以線性佈局,但仍然沒有改變。

<LinearLayout 
android:id="@+id/activity_main" 
android:orientation="vertical" 
android:weightSum="24"> 
    <MapHidder.SlidingUpPanelLayout 
     android:id="@+id/slidingLayout" 
     app:shadowHeight="0dp" 
     app:paralaxOffset="@dimen/paralax_offset" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="bottom"> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:layout_weight="8"> 
     <FrameLayout 
      android:id="@+id/frame" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      <fragment xmlns:map="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/map" 
       android:name="com.google.android.gms.maps.SupportMapFragment" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 
     </FrameLayout> 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" 
      android:layout_weight="16"> 
     <RelativeLayout 
      android:id="@+id/slidingContainer" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/frame"> 
      <View 
       android:id="@+id/transparentView" 
       android:visibility="gone" 
       android:layout_width="fill_parent" 
       android:layout_height="@dimen/map_height" 
       android:layout_alignParentTop="true" /> 

      <View 
       android:id="@+id/whiteSpaceView" 
       android:visibility="gone" 
       android:background="@android:color/darker_gray" 
       android:layout_marginTop="@dimen/map_height" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 

      <MapHidder.LockableListView 
       android:id="@+id/museumList" 
       android:cacheColorHint="@android:color/white" 
       android:drawSelectorOnTop="true" 
       android:dividerHeight="@dimen/divider_height" 
       android:divider="@android:color/darker_gray" 
       android:background="@android:color/transparent" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:smoothScrollbar="false" /> 
     </RelativeLayout> 
     </LinearLayout> 
    <MapHidder.SlidingUpPanelLayout> 
</LinearLayout> 
+0

給你的片段的修復高度可以說你的顯示高度的一半 –

+0

片段部分動態地調整其需要適應scrren,所以在這種情況下片段的默認值不幫助我 – Expiredmind

回答

0

嘗試......

<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:fitsSystemWindows="true"> 

    <MapHidder.SlidingUpPanelLayout 
     android:id="@+id/slidingLayout" 
     app:shadowHeight="0dp" 
     app:paralaxOffset="@dimen/paralax_offset" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <FrameLayout 
      android:id="@+id/frame" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      <fragment xmlns:map="http://schemas.android.com/apk/res-auto" 
       android:id="@+id/map" 
       android:name="com.google.android.gms.maps.SupportMapFragment" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" /> 

     </FrameLayout> 

     <RelativeLayout 
      android:id="@+id/slidingContainer" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/frame"> 
      <View 
       android:id="@+id/transparentView" 
       android:visibility="gone" 
       android:layout_width="fill_parent" 
       android:layout_height="@dimen/map_height" 
       android:layout_alignParentTop="true" /> 

      <View 
       android:id="@+id/whiteSpaceView" 
       android:visibility="gone" 
       android:background="@android:color/darker_gray" 
       android:layout_marginTop="@dimen/map_height" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"/> 

      <MapHidder.LockableListView 
       android:id="@+id/museumList" 
       android:cacheColorHint="@android:color/white" 
       android:drawSelectorOnTop="true" 
       android:dividerHeight="@dimen/divider_height" 
       android:divider="@android:color/darker_gray" 
       android:background="@android:color/transparent" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:smoothScrollbar="false" /> 

     </RelativeLayout> 
    </MapHidder.SlidingUpPanelLayout> 
</RelativeLayout> 

希望這會幫助你。