为什么我的android过渡使屏幕变黑?

时间:2015-02-17 17:32:49

标签: android api animation transition shared

我的共享转换问题视频

click to see the video of my problem

这是我在应用中所做的操作

我在CardView内部有一个共享视图(一个ImageView),当我点击CardView时,OnClick方法在CardView里面的位置基础上更改图像内部ImageView.setTransitionName(str)的ImageView.setTransitionName(str) RecyclerView。在onClick方法之后传递intent的转换名称,并创建ActivityOption。 之后,onCreate方法中的辅助Activity,恢复了转换名称,更改了辅助Activity中ImageView的名称。

为什么当我运行此代码时,我会看到这个故障?

private List<ContactInfo> contactList;
private Context context;
private Activity activity;

public ContactAdapterCustom(List<ContactInfo> contactList,Context context,Activity activity) {
    this.contactList = contactList;
    this.context = context;
    this.activity = activity;
}


@Override
public int getItemCount() {
    return contactList.size();
}

@Override
public void onBindViewHolder(ContactViewHolder contactViewHolder, int i) {
    ContactInfo ci = contactList.get(i);
    //contactViewHolder.vTitle.setText("reagente");
    //contactViewHolder.vCardView.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.vetreria));
    //contactViewHolder.vCardView.setBackgroundDrawable();
}

@Override
public ContactViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
        final View itemView = LayoutInflater.
                from(viewGroup.getContext()).
                inflate(R.layout.single_element_card_mockup, viewGroup, false);

        final String nome_transizione_condivisa = "immagine_numero_" + String.valueOf(i);

        itemView.setOnClickListener(new View.OnClickListener() {
            @TargetApi(Build.VERSION_CODES.LOLLIPOP)
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(context, InfoElementActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                ImageView immagine = (ImageView) itemView.findViewById(R.id.immagine_condivisa);
                immagine.setTransitionName(nome_transizione_condivisa);
                ActivityOptions options = ActivityOptions.makeSceneTransitionAnimation(activity,immagine,nome_transizione_condivisa);
                intent.putExtra("EXTRA_IMAGE_TRANSITION_NAME", nome_transizione_condivisa);
                context.startActivity(intent,options.toBundle());
            }
        });

        return new ContactViewHolder(itemView);
}

0 个答案:

没有答案