Я работаю над проектом, в котором мне нужно сделать общий переход. Я хочу выполнить переход на ImageView из моего всплеска Activity [First Activity] в действие входа [Second Activity], который имеет ImageView во фрагменте. Изображение в моей 1-й деятельности и изображение в фрагменте моей 2-й активности одинаковы и разделяют одно и то же имя перехода. Я не могу выполнить переход.Переход от элемента к фрагменту в другой активности
Мой Всплеск активности Кодекс Это
public class Splash extends Activity implements View.OnClickListener{
private ImageView imageView;
private String SharedElementname;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//getWindow().setExitTransition(R.transition.shared_element_transition_a);
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setSharedElementExitTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element_transition_a));
}
setContentView(R.layout.activity_splash);
imageView = (ImageView)findViewById(R.id.splashimage);
SharedElementname = getString(R.string.sharedname);
imageView.setOnClickListener(this);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_splash, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@SuppressLint("NewApi")
@Override
public void onClick(View v) {
ActivityOptionsCompat compat = ActivityOptionsCompat.makeSceneTransitionAnimation(this,v,SharedElementname);
Intent intent = new Intent(this, LoginActivity.class);
ActivityCompat.startActivity(this, intent, compat.toBundle());
}
Мои Войти активность Код @Override защищен недействительным OnCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(BuildConfig.MINT_API_ENABLED) {
Mint.initAndStartSession(LoginActivity.this, BuildConfig.MINT_API_KEY);
}
if (Build.VERSION.SDK_INT >= 21) {
getWindow().setSharedElementEnterTransition(TransitionInflater.from(this).inflateTransition(R.transition.shared_element_transition_a));
}
setContentView(R.layout.activity_login);
}
Some More Codes….
*****************************************************************************
Мой фрагмент кода в Вход Activty
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
loginTab = new LoginTab();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setSharedElementReturnTransition(TransitionInflater.from(
getActivity()).inflateTransition(R.transition.shared_element_transition_a));
setExitTransition(TransitionInflater.from(
getActivity()).inflateTransition(android.R.transition.fade));
loginTab.setSharedElementEnterTransition(TransitionInflater.from(
getActivity()).inflateTransition(R.transition.shared_element_transition_a));
loginTab.setEnterTransition(TransitionInflater.from(
getActivity()).inflateTransition(android.R.transition.fade));
}
}
Some More Codes….
*************************************************************************************
My Splash Acti Vity XML File
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background_new"
android:orientation="vertical"
android:weightSum="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
android:id="@+id/SplashLayout"
>
<ImageView
android:id="@+id/splashimage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/eventifyd_logo"
android:transitionName="@string/sharedname"
/>
</RelativeLayout>
</LinearLayout>
Мой переход XML File [Shared_element_transition]
<?xml version="1.0" encoding="utf-8"?>
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android" android:duration="5000">
<changeTransform />
<changeBounds />
<!—
I also tied ChangeImageTranform But Nothing Happened
-->
</transitionSet>
Мой фрагмент файла XML
<LinearLayout
android:layout_width="match_parent"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
>
<ImageView
android:id="@+id/profile_pic_login"
android:layout_above="@+id/login_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/eventifyd_logo"
android:transitionName="@string/sharedname"
/>
<TextView
android:layout_marginTop="30dp"
android:id="@+id/login_text"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/login_text"
style="@style/thin.white.large"/>
</RelativeLayout>
</LinearLayout>
Можете ли вы уточнить, что означает «Я неспособен выполнить переход» означает – o0rebelious0o
Переход изображения от моего 1-го занятия до фрагментации не происходит. Это похоже на то, что я хочу перейти, например, в Splash Screen приложения LiknedIn. Изображение в моей 1-й деятельности Должно быть в нижней части моей второй активности [которая находится во Фрагменте] и должна также немного увеличиться. Я не могу опубликовать изображение, иначе я бы вас проиллюстрировал. – Abhinash
Включены ли переходы в вашей теме? Попробуйте добавить 'getWindow(). RequestFeature (Window.FEATURE_CONTENT_TRANSITIONS);' – o0rebelious0o