带有半透明状态栏的Android表单滚动

时间:2014-11-06 08:43:04

标签: android statusbar

我的目标是SDK 21,Min SDK 15,在API 19设备上测试(Android 4.4.4)

我的活动

中有此代码
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_launcher);

    setTranslucentStatus();

}

@TargetApi(Build.VERSION_CODES.KITKAT)
private void setTranslucentStatus() {
    getWindow()
            .addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}

它有效,有一个问题。在布局中我有一个ScrollView。 ScrollView不滚动。但是,如果我注释掉对setTranslucentStatus()的调用,滚动就可以了。

顺便说一下,主题是NoActionBar

有关为什么ScrollView在状态栏为半透明时会拒绝滚动的任何线索?

2 个答案:

答案 0 :(得分:0)

我不知道你是否已经找到了解决方案,但是如果你使用ConstraintLayout应该解决这个烦人的bug。

示例布局如下所示

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">

<ScrollView
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintTop_toTopOf="parent">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </LinearLayout>

</ScrollView>

答案 1 :(得分:0)

只需使用滚动视图的属性即可 - 滚动条:滚动视图中没有滚动视图,滚动视图滚动滚动条  不需要半透明标志就可以删除它