Android的形式滚动半透明的状态栏
问题描述:
我瞄准SDK 21,闽SDK 15,测试API 19设备(安卓4.4.4)Android的形式滚动半透明的状态栏
对我有这样的代码在我的活动
@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
任何线索,为什么了滚动会拒绝滚动时,状态栏是透明的?
答
我不知道你是否已经找到了解决方案,但如果你使用ConstraintLayout应该解决这个恼人的错误。
样本布局看起来像这样
<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>
答
只需使用滚动视图 的属性 - 滚动条:在没有滚动视图它使滚动视图用了滚动条 无需半透明标志的滚动只是删除它
同样恼人的问题在这里,在棒棒糖我不能让ScrollView工作,同时在我的v21/styles.xml中设置Theme.Material.Light.NoActionBar.TranslucentDecor。试图设置filViewPort和AdjustResize参数,它们都不会。 – Stanislasdrg 2015-04-02 15:13:03
这里同样的问题。你找到了解决方案吗? – definera 2015-11-14 16:34:55
也有同样的问题。 – Mark13426 2016-10-03 04:53:39