Android Studio DrawerLayout scrimcolor 未显示
Android Studio DrawerLayout scrimcolor not showing
我有一个使用以下布局的 activity:
<android.support.v4.widget.DrawerLayout
android:id="@+id/root_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:openDrawer="start"
xmlns:tools="http://schemas.android.com/tools">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout_main_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout_main_activity"
app:tabIndicatorHeight="3dp"
app:tabIndicatorColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
android:fitsSystemWindows="true"
android:layout_gravity="start">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/drawer_header" />
<ExpandableListView
android:id="@+id/expandablelistview_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@null"
android:divider="@null"
android:dividerHeight="0dp"/>
</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>
我能想到的都试过了,比如;将 navigationView 放在 appbarlayout 的不同位置,将它放在 appbarlayout 之前和之后,最后尝试在 activity 的 oncreate 方法中动态设置 scrimcolor。 None 这些东西有效,有人知道我的问题的解决方案吗?
经过大量尝试,我成功了。我不清楚的原因,但这是有同样问题的人的工作布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/root_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:openDrawer="start"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/linearlayout_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout_main_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout_main_activity"
app:tabIndicatorHeight="3dp"
app:tabIndicatorColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
android:fitsSystemWindows="true"
android:layout_gravity="start">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/drawer_header" />
<ExpandableListView
android:id="@+id/expandablelistview_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@null"
android:divider="@null"
android:dividerHeight="0dp"/>
</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>
我有一个使用以下布局的 activity:
<android.support.v4.widget.DrawerLayout
android:id="@+id/root_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:openDrawer="start"
xmlns:tools="http://schemas.android.com/tools">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout_main_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout_main_activity"
app:tabIndicatorHeight="3dp"
app:tabIndicatorColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
android:fitsSystemWindows="true"
android:layout_gravity="start">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/drawer_header" />
<ExpandableListView
android:id="@+id/expandablelistview_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@null"
android:divider="@null"
android:dividerHeight="0dp"/>
</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>
我能想到的都试过了,比如;将 navigationView 放在 appbarlayout 的不同位置,将它放在 appbarlayout 之前和之后,最后尝试在 activity 的 oncreate 方法中动态设置 scrimcolor。 None 这些东西有效,有人知道我的问题的解决方案吗?
经过大量尝试,我成功了。我不清楚的原因,但这是有同样问题的人的工作布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
android:id="@+id/root_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:openDrawer="start"
xmlns:tools="http://schemas.android.com/tools">
<LinearLayout
android:id="@+id/linearlayout_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbarlayout_main_activity"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar_main_activity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<android.support.design.widget.TabLayout
android:id="@+id/tablayout_main_activity"
app:tabIndicatorHeight="3dp"
app:tabIndicatorColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager_main_activity"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigationview"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="@color/colorWindowBackground"
android:fitsSystemWindows="true"
android:layout_gravity="start">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="@layout/drawer_header" />
<ExpandableListView
android:id="@+id/expandablelistview_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:groupIndicator="@null"
android:divider="@null"
android:dividerHeight="0dp"/>
</LinearLayout>
</ScrollView>
</android.support.design.widget.NavigationView>