попробовать с этим -
установить изображение каждой строки с разными-разными именами перехода -
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
if (view == null) {
view = LayoutInflater.from(getContext()).inflate(R.layout.list_item, null);
}
TextView textView = (TextView) view.findViewById(R.id.textView);
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
textView.setTransitionName("transtext" + position);
imageView.setTransitionName("transition" + position);
}
return view;
}
}
затем нажмём, например -
ImageView imageView = (ImageView) view.findViewById(R.id.imageView);
TextView textView = (TextView) view.findViewById(R.id.smallerImageView);
EndFragment endFragment = new EndFragment();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
imageTransitionName = imageView.getTransitionName();
textTransitionName = textView.getTransitionName();
setSharedElementReturnTransition(TransitionInflater.from(
getActivity()).inflateTransition(R.transition.change_image_trans));
setExitTransition(TransitionInflater.from(
getActivity()).inflateTransition(android.R.transition.fade));
endFragment.setSharedElementEnterTransition(TransitionInflater.from(
getActivity()).inflateTransition(R.transition.change_image_trans));
endFragment.setEnterTransition(TransitionInflater.from(
getActivity()).inflateTransition(android.R.transition.fade));
}
Bundle bundle = new Bundle();
FragmentManager fragmentManager = getFragmentManager();
bundle.putString("TRANS_NAME", imageTransitionName);
bundle.putString("TRANS_TEXT", textTransitionName);
endFragment.setArguments(bundle);
fragmentManager.beginTransaction()
.replace(R.id.container, endFragment)
.addToBackStack("Payment")
.addSharedElement(imageView, imageTransitionName)
.addSharedElement(textView, textTransitionName)
.addSharedElement(staticImage, getString(R.string.fragment_image_trans))
.commit();
В EndFragment в oncreate метод получить ключ от имени перехода и установить на вид -
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Bundle bundle = getArguments();
String actionTitle = "";
Bitmap imageBitmap = null;
String transText = "";
String transitionName = "";
if (bundle != null) {
transitionName = bundle.getString("TRANS_NAME");
actionTitle = bundle.getString("ACTION");
imageBitmap = bundle.getParcelable("IMAGE");
transText = bundle.getString("TRANS_TEXT");
}
getActivity().setTitle(actionTitle);
View view = inflater.inflate(R.layout.fragment_end, container, false);
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
view.findViewById(R.id.listImage).setTransitionName(transitionName);
view.findViewById(R.id.smallerImageView).setTransitionName(transText);
}
((ImageView) view.findViewById(R.id.listImage)).setImageBitmap(imageBitmap);
((TextView) view.findViewById(R.id.smallerImageView)).setText(actionTitle);
return view;
}
связанные https://stackoverflow.com/a/31982516/3150663
Голосуйте мой ответ, если вы получили решение. :)
Если эти два вопроса идентичны, то они должны быть закрыты как дубликаты. Если это не так, тогда вы должны предоставить полный ответ здесь, а не только ответ на ссылку. – josliber
JaiSoni, @ JaiSoni отредактирован .. –