我不知道为什么,但似乎当工具栏崩溃时,会出现第二个状态栏.
我android:fitsSystemWindows="true"在所有组件中都使用过,因为如果没有这个,工具栏会从状态栏中显示出来.
这里有一些图片可以更好地解释:
图像
我从来没有见过这样的东西,我尝试了所有这些,但我不知道如何解决它.我在网上找不到任何东西.
这里的代码:
布局:
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:statusBarScrim="?attr/colorPrimaryDark"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed" >
<ImageView
android:id="@+id/photo_actor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_collapseMode="parallax"
android:fitsSystemWindows="true"
android:background="@drawable/background_protection" />
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:orientation="vertical">
<WebView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:id="@+id/webview_bio"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
活动创作:
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
CollapsingToolbarLayout collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
if(collapsingToolbarLayout!=null){
collapsingToolbarLayout.setTitle(advm.getName());
}
Run Code Online (Sandbox Code Playgroud)
样式:(我在当前活动中使用的那个是第二个)
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> …Run Code Online (Sandbox Code Playgroud) android statusbar material-design android-coordinatorlayout android-collapsingtoolbarlayout