我正在使用以下库:https ://github.com/umano/AndroidSlidingUpPanel 。
我想在滚动时在状态栏下方显示内容,但我无法使 main_content(SlidingUpPanelLayout 的第一个容器)适合屏幕。我想在滚动时在状态栏下方显示内容。
这是我的第一个 xml 配置:
<android.support.v4.widget.DrawerLayout
...
android:fitsSystemWindows="true">
<com.hnhh.app3.fragments.model.FitsSystemWindowsFrameLayout
...
android:fitsSystemWindows="true">
<!-- This is where I don't get what I want,
This container has always a padding top equals to the
status bar size, so it will always affect the direct
childs => main_content (my fragments container) -->
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" // seems to not be supported
android:gravity="bottom"
...>
<!-- Main content - fragments placeholder -->
<com.hnhh.app3.fragments.model.FitsSystemWindowsFrameLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true" // if the parent doesn't it will not either.
tools:background="@color/colorAccent" />
<!-- Panel -->
<FrameLayout
android:id="@+id/..."
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:fitsSystemWindows="false" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<com.hnhh.app3.widgets.BannerAdWrapper.../>
</FrameLayout>
</com.hnhh.app3.fragments.model.FitsSystemWindowsFrameLayout>
<include layout="@layout/navigation" />
</android.support.v4.widget.DrawerLayout>
我尝试了几个父母的sliding_layout,但我无法获得所需的行为。滑动布局永远不适合屏幕。
我尝试的另一种可行的方法是用一个空的 ViewGroup 替换 main_content ,该 ViewGroup 必须匹配_paren (库希望这样)并且 main_content 不在 SlidingUpPanelLayout 内部,而是在之前。
<android.support.v4.widget.DrawerLayout >
<com.hnhh.app3.fragments.model.FitsSystemWindowsFrameLayout>
<!-- NEW Main content - fragments placeholder -->
<com.hnhh.app3.fragments.model.FitsSystemWindowsFrameLayout />
<com.sothree.slidinguppanel.SlidingUpPanelLayout>
<!-- Replaced old main_content with empty -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<!-- Panel -->
<FrameLayout />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
<FrameLayout>
<com.hnhh.app3.widgets.BannerAdWrapper/>
</FrameLayout>
</com.hnhh.app3.fragments.model.FitsSystemWindowsFrameLayout>
<include layout="@layout/navigation" />
</android.support.v4.widget.DrawerLayout>
第二种解决方案的问题是我有一个空容器,它将拦截所有触摸事件,我无法将它们传递给主要内容。
有没有人有解决方法?谢谢