【问题标题】:Android: sliding drawer content overlapping the whole screenAndroid:滑动抽屉内容覆盖整个屏幕
【发布时间】:2015-10-26 10:48:23
【问题描述】:

我有一个使用滑动抽屉的应用程序。我必须进行一些更改,滑动抽屉内容是一个简单的相对布局,但我必须更改它以包含一个片段。

这是更改前的滑块布局:

<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();

之前的滑块内容,已被移动(未更改)到单独的布局文件中,以在新创建的片段中使用。

以前,滑块可以很好地工作,但现在我看到片段内容与活动内容重叠(见下面的屏幕截图),也不仅限于滑块空间,而是占据了整个屏幕

正如您在屏幕截图中看到的那样,滑块已打开并且它占据了屏幕上的正确部分(请参阅处理程序的位置 [右侧中间的小橙色矩形),所以我认为问题是实际上片段内容没有被定位在滑块内

谁能帮我解决这个问题?

【问题讨论】:

    标签: android android-layout android-fragments fragment slide


    【解决方案1】:

    看起来像这样一行:

    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();
    

    解决了问题

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-25
      • 1970-01-01
      • 2017-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-09
      相关资源
      最近更新 更多