hit*_*ted 24 android navigationbar android-fragments android-viewpager
我无法阻止系统导航栏覆盖我的内容!

我滚动到recyclerview的最底部,但它隐藏在导航栏后面.这是我的XML布局.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<include layout="@layout/toolbar"/>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:fitsSystemWindows="true"
android:id="@+id/viewpager"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.melnykov.fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="16dp"
app:fab_colorNormal="@color/accent"
app:fab_colorPressed="@color/accent_dark" />
Run Code Online (Sandbox Code Playgroud)
这是您在图片中看到的片段布局.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical"/>
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
我已经尝试将android:fitsSystemWindows ="true"添加到我可以的每一个布局中,但是没有用.其他线程提到从条形图计算增加保证金,但这似乎不是正确的解决方案.我直接从谷歌的CheesSquare应用程序演示了appbarlayout这个布局,看起来它的工作正常.
我想到了。在我的特定情况下,我的每个片段都管理自己的工具栏实例。我在片段的 onViewCreated() 方法中调用 setSupportActionBar() 。将此功能移至 onCreateView() 解决了这个问题。
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_my_account, container, false);
setupToolbar((Toolbar) view.findViewById(R.id.toolbar));
return view;
}
private void setupToolbar(Toolbar toolbar) {
toolbarController.registerToolbar(toolbar);
toolbarController.setActivityTitle("My Account");
}
Run Code Online (Sandbox Code Playgroud)
(registerToolbar() 在托管活动中调用 setSupportActionBar())。
希望这对大家有帮助!
| 归档时间: |
|
| 查看次数: |
7270 次 |
| 最近记录: |