Android BottomNavigationView对SlidengAppAnnelLayout动作作出反应
我一直在尝试在com.sothree.slidinguppanel.slidinguppanel布局movements上制作一些底部导航视图的动画。 以下是我的布局:Android BottomNavigationView对SlidengAppAnnelLayout动作作出反应,android,bottomnavigationview,Android,Bottomnavigationview,我一直在尝试在com.sothree.slidinguppanel.slidinguppanel布局movements上制作一些底部导航视图的动画。 以下是我的布局: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.c
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<com.sothree.slidinguppanel.SlidingUpPanelLayout
android:id="@+id/slidingUpPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.test.activity.MainActivity"
tools:showIn="@layout/activity_main"
android:gravity="bottom"
android:layout_above="@+id/bottom_nav_view"
app:umanoPanelHeight="50dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin"/>
</RelativeLayout>
<fragment
android:id="@+id/invitationFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.test.fragment.CustomListFragment" />
</com.sothree.slidinguppanel.SlidingUpPanelLayout>
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_nav_view"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
app:itemIconTint="@drawable/item_bottom_bar_bg"
app:itemTextColor="@drawable/item_bottom_bar_bg"
app:elevation="0dp"
app:menu="@menu/bottom_navigation" />
</RelativeLayout>
我还尝试将CoordinatorLayout作为俯视图与BottomNavigationViewBehavior合并,以扩展CoordinatorLayout.Behavior,但没有成功
我也一直在尝试收听面板上的事件(slidingUpPanelLayout.setonscrollchangellistener&slidingUpPanelLayout.setondraglister),但令人窒息的是,它们从未被调用过
我正在使用以下版本:
- android支持库25.3.1
- slidenguppanel:library:3.3.0
谢谢。我最终使用BottomSheetBehavior+它的回调来设置BottomNavigationBar的动画。 布局如下:
<RelativeLayout
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="match_parent">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginRight="@dimen/activity_horizontal_margin">
</FrameLayout>
<android.support.design.widget.CoordinatorLayout
android:id="@+id/coordinator_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:background="@color/light_grey"
android:id="@+id/bottom_sheet"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:layout_behavior="android.support.design.widget.BottomSheetBehavior"
app:behavior_hideable="true"
app:behavior_peekHeight="120dp">
<fragment
android:id="@+id/invitationFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.test.view.fragment.InvitationListFragment" />
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.BottomNavigationView
android:background="@color/white"
android:id="@+id/bottom_nav_view"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_alignParentBottom="true"
app:itemIconTint="@drawable/item_bottom_bar_bg"
app:itemTextColor="@drawable/item_bottom_bar_bg"
app:elevation="0dp"
app:menu="@menu/bottom_navigation"
android:visibility="visible"/>
</RelativeLayout>
平滑动画(底部导航栏向下,底部工作表向上滚动,反之亦然):
你不用底纸吗?它具有我认为相同的功能。感谢您的建议,我已经能够使用BottomSheetBehavior.BottomSheetCallback.onSlide向下滑动我的BottomNavigation视图。很高兴听到这一点,我的帮助是:)
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
slideDown(bottomNavigationView,slideOffset);
}
});
private void slideDown(BottomNavigationView child, float slideOffset) {
float heigh_to_animate = slideOffset * child.getHeight();
ViewPropertyAnimator animator = child.animate();
animator
.translationY(heigh_to_animate)
.setInterpolator(new DecelerateInterpolator())
.setDuration(0)
.start();
}