我无法使用MapView制作ConstraintSet动画

时间:2019-08-16 15:04:27

标签: java android kotlin android-mapview constraintset

我想创建一个列表,该列表将以列表格式和地图形式显示数据列表。但是,当第一次尝试时,它做的很好,但是再次显示地图时,它却没有显示


fun changeView(view:View?){
        val c1 = ConstraintSet()
        c1.clone(findViewById<View>(R.id.nearby_home) as ConstraintLayout)
        val c2 = ConstraintSet()
        c2.clone(this, R.layout.activity_near_by_user_list)
        TransitionManager.beginDelayedTransition(findViewById(R.id.nearby_home))
        val c = if (set) c1 else c2
        if(set){
            nearByList?.setLayoutManager(LinearLayoutManager(this,RecyclerView.HORIZONTAL,false))
        }else{
            nearByList?.setLayoutManager(LinearLayoutManager(this,RecyclerView.VERTICAL,false))
        }
        c.applyTo(findViewById(R.id.nearby_home))
        set = !set
    }
<!--1st layout -->
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:background="@drawable/basic_bg"
    android:id="@+id/nearby_home"
    tools:context=".pages.nearByUsers.NearByUserActivity">



    <androidx.appcompat.widget.AppCompatTextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="12dp"
        android:id="@+id/near_by_change_view"
        android:layout_marginBottom="8dp"
        android:background="@drawable/sort_filter_bg"
        android:elevation="15dp"
        android:fontFamily="@font/sf_ui_bold"
        android:padding="8dp"
        android:paddingStart="20dp"
        android:onClick="changeView"
        android:paddingEnd="20dp"
        android:text="@string/list_view"
        android:textColor="@color/white"
        app:layout_constraintBottom_toTopOf="@+id/near_by_list"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent" />
<!-Custom recyclerview -->
    <com.smartersstudio.prorecyclerview.ProRecyclerView
        android:id="@+id/near_by_list"
        android:layout_width="match_parent"
        android:layout_height="150dp"
        android:padding="8dp"
        android:elevation="10dp"
        app:layout_constraintBottom_toTopOf="@id/sort_filter_layout"
        />
    <com.google.android.gms.maps.MapView
        android:id="@+id/near_by_map"
        android:layout_width="0dp"
        android:layout_height="0dp"
        android:padding="8dp"
        app:layout_constraintBottom_toTopOf="@id/sort_filter_layout"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toBottomOf="@id/near_by_user_count" />


</androidx.constraintlayout.widget.ConstraintLayout>

以下是过渡的两种布局 交易是从地图到列表完成的,但不是从列表到地图完成的

0 个答案:

没有答案