小编bri*_*ith的帖子

共享内容重叠底部导航

我的MainActivity有一个RecyclerView和一个BottomNavigationView。RecyclerView中的项目是CardViews。

当我单击被BottomNavigationView遮住一半的项目时(-将其称为BNV),它会“弹出”在BNV上,然后向上滑动以成为LaunchedActivity中的标题。

当退出LaunchedActivity时,它会滑到BNV上方,然后“快速捕捉”回原位:

在此处输入图片说明

我怎么可以:

  1. 如果共享内容似乎从BNV下方滑动,或者失败,
  2. 让共享内容开始不可见,并在滑动到页眉时淡出

我尝试使用BNV的高度,尝试将sharedElementEnterTransition设置为Fade(),尝试使用BottomNavigation指定excludeTarget;我似乎无法使事情如我所愿。

这是MainActivity的布局:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity">
    <android.support.v7.widget.RecyclerView
            android:id="@+id/rv"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_marginStart="8dp"
            android:layout_marginEnd="8dp"
            android:layout_marginTop="8dp"
            android:layout_marginBottom="8dp"
            app:layout_constraintBottom_toTopOf="@+id/bottomNavigationView"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            />
    <android.support.design.widget.BottomNavigationView
            android:id="@+id/bottomNavigationView"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:menu="@menu/navigation"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
           />
</android.support.constraint.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

Activity_launched在这里:

<?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"
        tools:context=".LaunchedActivity">

    <android.support.design.widget.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"/>

    </android.support.design.widget.AppBarLayout>

    <include layout="@layout/content_launched"/>

    <android.support.design.widget.FloatingActionButton
            android:id="@+id/fab"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom|end"
            android:layout_margin="@dimen/fab_margin"
            app:srcCompat="@android:drawable/ic_dialog_email"/>

</android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

并且content_launched:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout …
Run Code Online (Sandbox Code Playgroud)

android android-animation kotlin

9
推荐指数
1
解决办法
226
查看次数

标签 统计

android ×1

android-animation ×1

kotlin ×1