我有一个底部导航视图的设置。我加载的 3 个片段之一有一个带有另外 3 个片段的标签栏。我确实在底部导航点击时替换了这样的片段:
private void loadPage(int page)
{
if(fragmentManager == null)
fragmentManager = getSupportFragmentManager();
final FragmentTransaction transaction = fragmentManager.beginTransaction();
//transaction.setCustomAnimations(R.anim.fragment_fade_in, R.anim.fragment_fade_out, R.anim.fragment_fade_in, R.anim.fragment_fade_out);
//transaction.setCustomAnimations(R.anim.fragment_fade_in, R.anim.fragment_fade_out, R.anim.fragment_fade_in, R.anim.fragment_fade_out);
switch (page)
{
//Property
case TAB_PROPERTIES:
Fragment fragment = fragmentManager.findFragmentByTag("property");
if(fragment == null)
fragment = PropertyFragment.newInstance();
transaction.replace(R.id.rlMainContent, fragment,"property").addToBackStack("property").commit();
break;
//jobs
case TAB_JOBS:
fragment = fragmentManager.findFragmentByTag("jobs");
if(fragment == null)
fragment = JobsFragment.newInstance(null);
transaction.replace(R.id.rlMainContent, fragment,"jobs").addToBackStack("jobs").commit();
break;
//contacts
case TAB_CONTACTS:
fragment = fragmentManager.findFragmentByTag("contacts");
if(fragment == null)
fragment = PersonalContactsFragment.newInstance(false,true,false,true);
transaction.replace(R.id.rlMainContent, fragment,"contacts").addToBackStack("contacts").commit();
break;
}
} …Run Code Online (Sandbox Code Playgroud) 大家好
我正在尝试正确完成我的布局的scroll_behaviour。我的问题是,如果我将底部导航包装到相对的布局中,然后将主要内容放在其上方,那么当工具栏隐藏时,底部导航会滚动出屏幕。如果将底部导航作为协调器布局的另一个直接子级,则主要内容在我的BottomNavigation之后。我不想在主导航栏的底部添加填充/边距来解决此问题。您有什么提示或想法吗?
另一件事是,我的底部导航的涟漪效应仅在底部导航的顶部可见,而在我的主要内容之上而不可见。
向底部导航添加scroll_behaviour也不起作用。我想尝试固定的底部导航,或者在向下滚动时添加滚动动画,如google材质设计指南中所示。
这里的截图:
这是布局代码:
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
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"
>
<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"
app:elevation="0dp"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_scrollFlags="scroll|enterAlways"
>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:id="@+id/rl"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<com.getproperly.properlyv2.classes.misc.CustomViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_anchorGravity="bottom"
app:layout_anchor="@id/rl"
app:menu="@menu/bottom_navigation_main"
/>
<com.getproperly.properlyv2.classes.misc.SelfAwareFloatingActionButton
android:id="@+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_white"
app:fabSize="normal"
app:layout_anchor="@id/rl"
app:layout_anchorGravity="bottom|right|end"
app:layout_behavior="com.getproperly.properlyv2.classes.misc.ScrollAwareFABBehavior"
android:layout_marginEnd="@dimen/fab_margin"
android:layout_marginLeft="@dimen/fab_margin"
android:layout_marginRight="@dimen/fab_margin"
android:layout_marginStart="@dimen/fab_margin"
android:layout_marginTop="@dimen/fab_margin"
android:layout_marginBottom="64dp"/>
Run Code Online (Sandbox Code Playgroud)
感谢任何帮助!谢谢
android scrollable android-toolbar android-coordinatorlayout bottomnavigationview