我有GridView
,我想像animation
谷歌游戏商店.在那里,当我们点击任何应用程序时,它会重定向到其详细信息页面.那时会发生一些小动画.我希望这种动画可以用于我GridView
的细节页面.如果有人意识到这种活动从一个班级转到另一个班级,我需要帮助.
这是您要移动到详细信息屏幕的第一个活动代码
import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.util.Pair; import android.support.v7.app.AppCompatActivity; import android.view.View; public class StartActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_start); } public void onClick(View view) { View imageView = findViewById(R.id.imageView); View textView = findViewById(R.id.textView); View button = findViewById(R.id.button); Intent intent = new Intent(this, EndActivity.class); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { textView.setTransitionName(getString(R.string.activity_text_trans)); button.setTransitionName(getString(R.string.activity_mixed_trans)); Pairpair1 = Pair.create(imageView, imageView.getTransitionName()); Pair pair2 = Pair.create(textView, textView.getTransitionName()); Pair pair3 = Pair.create(button, button.getTransitionName()); ActivityOptionsCompat options = ActivityOptionsCompat. makeSceneTransitionAnimation(this, pair1, pair2, pair3); startActivity(intent, options.toBundle()); } else { startActivity(intent); } } }
这是详细信息屏幕活动
import android.os.Build; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.view.View; public class EndActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_end); View smallImageView = findViewById(R.id.textView); View editText = findViewById(R.id.editText); if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { smallImageView.setTransitionName(getString(R.string.activity_text_trans)); editText.setTransitionName(getString(R.string.activity_mixed_trans)); } } }
FirstActivity layouut文件
EndActivity xml布局文件