【发布时间】:2016-01-11 15:59:06
【问题描述】:
我已经使用 https://github.com/umano/AndroidSlidingUpPanel 实现了 UmanoSlidingPanel。一切正常,除了我的滑动面板在展开时,滑动内容(sliding_view)在状态栏下方。我怎样才能避免这种情况?我尝试删除
<item name="android:windowTranslucentStatus">true</item>
来自styles.xml,但这使得状态栏对于主要内容也是不透明的。有什么办法解决这个问题?
<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
android:id="@+id/sliding_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
sothree:umanoDragView="@+id/firstPanelDragArea"
sothree:umanoPanelHeight="@dimen/bottom_panel_height"
sothree:umanoShadowHeight="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<!-- SLIDING LAYOUT -->
<LinearLayout
android:id="@+id/firstPanelDragArea"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/sliding_view" />
</LinearLayout>
styles.xml
<style name="AppTheme" parent="@style/Theme.AppCompat">
<item name="windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="windowNoTitle">true</item>
</style>
编辑
public void onPanelSlide(View panel, float slideOffset) {
if (slideOffset > 0.5 && !flagTransparent) {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
flagTransparent = true;
Log.i(TAG, "onPanelSlide, offset " + slideOffset);
} else if (slideOffset < 0.5 && flagTransparent){
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
flagTransparent = false;
Log.i(TAG, "onPanelSlide, offset " + slideOffset);
}
【问题讨论】:
标签: android android-layout android-sliding