2015-10-26 45 views
0

我有一個使用滑動抽屜的應用程序。我不得不做一些改變,滑動抽屜內容是一個簡單的相對佈局,但我不得不改變它以包含一個片段。Android:滑動抽屜內容重疊整個屏幕

這是變化前滑塊佈局:

<SlidingDrawer 
      android:id="@+id/drawer" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:orientation="horizontal" 
      android:handle="@+id/handle" 
      android:rotation="180" 
      android:content="@+id/content"> 

      <ImageView 
       android:id="@id/handle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/handle" 
       android:rotation="180" 
       /> 

      <RelativeLayout 
       android:id="@id/content" 
       android:background="@drawable/border" 
       android:layout_width="140dip" 
       android:layout_height="fill_parent" 
       android:orientation="vertical" 
       android:rotation="180" 
       android:focusable="true" 
       android:focusableInTouchMode="true"> 

       <EditText 
        android:drawableLeft="@android:drawable/ic_menu_search" 
        android:layout_width="fill_parent" 
        android:layout_height="50dp" 
        android:id="@+id/editInp" 
        android:layout_marginLeft="20dip" 
        android:imeOptions="actionDone" 
        android:layout_marginRight="20dip" 
        android:layout_marginTop="15dip" 
        android:hint="" 
        android:textColor="@color/themeapp" 
        android:background="@drawable/layout_corner_white" 
        android:singleLine="true" 
        android:inputType="textNoSuggestions"/> 

       <ImageView 
        android:id="@+id/clear_button" 
        android:layout_width="35dp" 
        android:layout_height="35dp" 
        android:layout_marginTop="23dip" 
        android:layout_alignRight="@id/editInp" 
        android:src="@android:drawable/ic_menu_close_clear_cancel"/> 

       <RelativeLayout 
        android:id="@+id/progress_conteiner" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_above="@+id/footer1" 
        android:layout_below="@+id/header1" 
        android:visibility="gone"> 

        <ProgressBar 

         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_centerInParent="true" 
         style="?android:attr/progressBarStyle"/> 
       </RelativeLayout> 

       <ExpandableListView 
        android:id="@+id/list" 
        android:layout_below="@+id/editInp" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:paddingTop="20dip" 
        android:layout_alignParentBottom="true" 
        android:layout_alignParentRight="true" 
        android:layout_alignParentEnd="true" 
        android:divider="@color/themeapp" 
        android:dividerHeight="1dp" 
        android:indicatorRight="300dp" /> 
      </RelativeLayout> 
</SlidingDrawer> 

更改後它看起來像這樣:

<SlidingDrawer 
      android:id="@+id/drawer" 
      android:layout_width="140dp" 
      android:layout_height="fill_parent" 
      android:layout_alignParentTop="true" 
      android:orientation="horizontal" 
      android:handle="@id/handle" 
      android:rotation="180" 
      android:content="@id/content_frame"> 

      <ImageView 
       android:id="@+id/handle" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/handle" 
       android:rotation="180" 
       /> 

      <FrameLayout 
       android:id="@+id/content_frame" 
       android:layout_width="140dp" 
       android:layout_height="fill_parent" > 
      </FrameLayout> 

</SlidingDrawer> 

java代碼以膨脹片段:

getActivity().getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FragmentFleetListMap(this)).commit(); 

的上一個滑塊內容已被移動(不變)到一個單獨的佈局文件,以便在新創建的Crea中使用特德片段。

之前,滑塊工作WEEL,但現在我看到的片段內容重疊的活動內容(見screeenshot下文),也不僅限於滑塊空間,但你可以佔據整個屏幕

在屏幕截圖中看到滑塊已打開並且屏幕上顯示了正確的部分(請參閱處理程序的位置[右側中間的小橙色矩形),所以我認爲問題實際上是片段內容是沒有被放置在滑塊內

有人能幫助我嗎?

see screeenshot

回答

0

看起來像這樣一行:

getActivity().getSupportFragmentManager().beginTransaction().add(R.id.content_frame, new FragmentFleetListMap(this)).commit(); 

被 「添加」 包含列表在mapfragment代替的FrameLayout我的片段。將其更改爲:

getChildFragmentManager().beginTransaction().add(R.id.content_frame, new FragmentFleetListMap(this)).commit(); 

解決了這個問題