0

アンドロイドの移行に問題があります。私は、複数の要素を持つrecyclerviewリストを持っています。アニメーションは、クリックされたときにどの行のイメージからも開始する必要がありますが、行の中央から開始します。遷移アニメーションの開始位置が間違っています

IはRecyclerView有するフラグメントを有する、遷移が

fragment_states始まるここで:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="namespace.fragments.StatesFragment"> 

    <android.support.v7.widget.RecyclerView 
     android:id="@+id/recyclerViewStates" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
    android:layout_marginBottom="?attr/actionBarSize" 
    /> 
</FrameLayout> 

を前recyclerViewは、以下に示すように、列が定義されているリスト・アダプタを有します。ここでは、android:transitionName = "stateImage"を定義しました。これは、遷移が開始されるべきイメージです。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" android:layout_width="match_parent" 
android:layout_height="wrap_content"> 
    <ImageView 
     android:id="@+id/imgState" 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:transitionName="stateImage" 
     android:padding="6dp" /> 
<TextView 
    android:padding="10dp" 
    android:layout_toRightOf="@id/imgState" 
    android:id="@+id/txtNombreEstado" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerVertical="true" 
    android:textAppearance="@style/Base.TextAppearance.AppCompat.Medium" 
    /> 
</RelativeLayout> 

ここで私はトランジションを呼び出す方法は次のとおりです。

StatesFragment.java

public class StatesFragment extends Fragment { 
... 
@Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
          Bundle savedInstanceState) { 

recyclerView.addOnItemTouchListener(new Helper.RecyclerTouchListener(getActivity(), recyclerView, new Helper.ClickListener() { 
      @Override 
      public void onClick(View view, int position) { 

       try {  
        Intent intent = new Intent(getActivity(), CitiesActivity.class); 

        //Check if we're running on Android 5.0 or higher 
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 
         // Call some material design APIs here 
         ActivityOptionsCompat options = ActivityOptionsCompat. 
           makeSceneTransitionAnimation(getActivity(), view, "stateImage"); 
         startActivity(intent, options.toBundle()); 
        } else { 
         // Implement this feature without material design 
         startActivity(intent); 
        } 


       } 
       catch (Exception ex) 
       { 

       } 
      } 

      @Override 
      public void onLongClick(View view, int position) { 

      } 
     })); 
} 

私が間違ってやっている上の任意のidead?

答えて

1

私の間違いは、このラインにあった:

ActivityOptionsCompat options = ActivityOptionsCompat. 
           makeSceneTransitionAnimation(getActivity(), view, "stateImage"); 

私は、行、この場合には、ビューを渡しました。これは私がそれを固定した方法です

final ImageView image = (ImageView) 
          view.findViewById(R.id.stateImage); 

ActivityOptionsCompat options = ActivityOptionsCompat. 
           makeSceneTransitionAnimation(getActivity(), image, "stateImage"); 
関連する問題