我正在尝试切换应用程序以使用Theme.Material,我有一个工具栏设置,fitSystemWindows设置为true但我的活动扩展到导航栏下方!!
这是我的主题
<style name="FlowTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowFullscreen">false</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="cpvColor">@color/accent</item>
<item name="cpvStrokeWidth">3dp</item>
<item name="cpvCircleAnimDuration">1400</item>
<item name="cpvSweepAnimDuration">950</item>
</style>
我的活动中没有任何东西可以标记全屏
发生了什么事?我如何解决这个问题,以免它全屏?
编辑:这是我的主要活动XML
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bg_color"
android:orientation="vertical">
<include
android:id="@+id/toolbar_actionbar"
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ActMain"
tools:ignore="MergeRootFrame"
android:layout_below="@+id/toolbar_actionbar" />
</LinearLayout>
<fragment
android:id="@+id/fragment_drawer"
android:name="com.metalab.flow.ui.fragments.FrNavigationDrawer"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
app:layout="@layout/fr_navigation_drawer" />
答案 0 :(得分:1)
这就是原因
Theme.AppCompat.Light.NoActionBar // i show no actionbar..
将其放入您的活动xml布局中,如果其linearLayout
让它成为第一个孩子,如果其RelativeLayout
让它在顶部并且所有孩子都应该与它对齐..
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
app:theme="@style/FlowTheme" />
式
<style name="FlowTheme" parent="Theme.AppCompat.Light">
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primaryDark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:windowFullscreen">false</item>
<item name="android:fitsSystemWindows">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="cpvColor">@color/accent</item>
<item name="cpvStrokeWidth">3dp</item>
<item name="cpvCircleAnimDuration">1400</item>
<item name="cpvSweepAnimDuration">950</item>
</style>
答案 1 :(得分:0)
事实证明我正在使用这个类,用于核心WebView错误修复https://github.com/madebycm/AndroidBug5497Workaround
删除它的用法修复了我的问题,但是WebView调整大小错误仍然存在...
答案 2 :(得分:0)
您正在工具栏中使用wrap_content,如果您没有给予支持,那么它没有要显示的内容。我建议你将工具栏的高度更改为:
android:layout_height="?attr/actionBarSize"
你应该在你的java文件中提供支持来显示标题和按钮:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar_actionbar);
setSupportActionBar(toolbar);
编辑:我阅读了其他一些回复,并添加了更多信息,因为我认为您在其他xml中定义了工具栏。这是您应该包含的工具栏示例:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:translationZ="4dp"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />