当我尝试将片段加上CoordinatorLayout+ 时,我遇到了问题AppBarLayout.
我尝试将不同的片段加载到具有属性的ActionBar下面的RelativeLayout内容中,app:layout_behavior="@string/appbar_scrolling_view_behavior"但是当我在屏幕底部加载带有两个按钮的片段时,这些片段被加载到屏幕外.
加载片段的内容在屏幕外,内容总是从底部开始.
这是我的代码main_activity.xml:
<?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:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".views.activities.HomeActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent"
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"
app:layout_scrollFlags="scroll|enterAlways" /> <!-- Indica como afecta a los hijos de AppBar -->
</android.support.design.widget.AppBarLayout>
<!-- Fragment are loaded here -->
<RelativeLayout
android:id="@+id/containerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" >
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)
这是屏幕内容的屏幕截图.
这是在模拟器中加载片段的屏幕截图.您可以看到底部按钮的显示方式.它们被导航栏隐藏:
我该如何防止这个问题?
编辑
<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:id="@+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".views.activities.HomeActivity">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout"
android:layout_height="wrap_content"
android:layout_width="match_parent" …Run Code Online (Sandbox Code Playgroud) android android-fragments android-coordinatorlayout android-support-design android-appbarlayout
android ×1