gpt4 book ai didi

android - 使用 overridePendingTransition 滑动过渡

转载 作者:行者123 更新时间:2023-11-28 16:15:07 35 4
gpt4 key购买 nike

我试图在两个 Activity 之间滑动,但没有效果。我需要一种特殊的风格吗?我正在研究“Theme.AppCompat.Light.NoActionBar”

我试过“淡入/淡出”过渡,效果很好。但是幻灯片不是..有什么问题吗?

资源/动画/进入:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate android:fromXDelta="-100%" android:toXDelta="0%"
android:duration="700"/>
</set>

res/anim/leave:

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="100%"
android:duration="700" />
</set>

新 Activity :

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.overridePendingTransition(R.anim.enter,
R.anim.leave);
setContentView(R.layout.activity_analyzer);
}

主要 Activity :

 @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Mylist = (ListView) findViewById(R.id.navigation_list);
drawerLayout = (DrawerLayout) findViewById(R.id.navigation);
Mylist.setAdapter(new CustomListViewAdapter(getApplicationContext()));
actionBarDrawerToggle = new ActionBarDrawerToggle(MainActivity.this,drawerLayout,toolbar,R.string.app_name,R.string.app_name);


Mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

if(newposition == 7) {
drawerLayout.closeDrawers();
Intent toAnalyzer = new Intent(MainActivity.this, Analyzer.class);
startActivity(toAnalyzer);
overridePendingTransition(R.anim.enter,
R.anim.leave);

}
}
});

最佳答案

你应该把它放在之前的 Activity 中,像这样:

    // after startActivity(intent);
overridePendingTransition(R.anim.enter,
R.anim.leave);

关于android - 使用 overridePendingTransition 滑动过渡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37659804/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com