布局不占用整个屏幕
Layout doesn't take up whole screen
我正在尝试在我的 styles.xml 中使用 <item name="android:windowTranslucentNavigation">true</item>
并通过将 android:fitsSystemWindows="true"
添加到我的布局中来在我的导航栏下呈现我的 activity_main
。由于某种原因,布局没有使用所有可用的 space,而是将自身置于可用的 space 中:
我的main_activity
:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.smc_kr.gachi_soundboardv2.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
我的content_main
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.smc_kr.gachi_soundboardv2.MainActivity"
tools:showIn="@layout/activity_main">
<GridView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/gridview"
android:numColumns="auto_fit"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:gravity="center"
android:stretchMode="columnWidth"
android:columnWidth="100dp">
</GridView>
</RelativeLayout>
我的风格 21:
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
所有维度值都设置为 0dp。
我在这里遗漏了什么吗?
尝试删除 content_main.xml
中的所有填充
从网格视图中删除 android:gravity="center" 或将其置于顶部
我通过将 content_main
中的 RelativeLayout
替换为 ScrimInsetsFrameLayout
来修复此问题。
我正在尝试在我的 styles.xml 中使用 <item name="android:windowTranslucentNavigation">true</item>
并通过将 android:fitsSystemWindows="true"
添加到我的布局中来在我的导航栏下呈现我的 activity_main
。由于某种原因,布局没有使用所有可用的 space,而是将自身置于可用的 space 中:
我的main_activity
:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.example.smc_kr.gachi_soundboardv2.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="@layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
我的content_main
:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:fitsSystemWindows="true"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.smc_kr.gachi_soundboardv2.MainActivity"
tools:showIn="@layout/activity_main">
<GridView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="@+id/gridview"
android:numColumns="auto_fit"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp"
android:gravity="center"
android:stretchMode="columnWidth"
android:columnWidth="100dp">
</GridView>
</RelativeLayout>
我的风格 21:
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:windowTranslucentNavigation">true</item>
</style>
</resources>
所有维度值都设置为 0dp。 我在这里遗漏了什么吗?
尝试删除 content_main.xml
中的所有填充从网格视图中删除 android:gravity="center" 或将其置于顶部
我通过将 content_main
中的 RelativeLayout
替换为 ScrimInsetsFrameLayout
来修复此问题。