1

모든 파편을 바꿀 수있는 아래쪽 탐색 뷰가있는 액티비티 (Home Activity라고 부름)가 있습니다. 홈 액티비티에서 검색 아이콘이있는 조각을로드했습니다. 해당 검색 아이콘은 검색 활동 인 활동으로 리디렉션됩니다.액티비티의 조각을 이미 백 스택에있는 다른 액티비티에로드하기

검색 결과 중 하나를 클릭하면 내 홈 활동으로 이동하고 이전 조각을 바꿔서 최근 검색 결과 클릭 구현을 표시합니다.

이 경우 복잡도는 이전 조각을 대체하려고 할 때 사용자에게 표시됩니다. 전환 애니메이션이있는 경우 - 이전 조각이 종료되고 최신 조각이 들어가는 것을 볼 수 있습니다.

사용자에게 좋은 것은 아닙니다. 이전 조각이 사용자에게 표시되지 않도록 기능을 어떻게 향상시킬 수 있습니까?

답변

0

조각은 기본적으로 투명합니다. 따라서 검색 결과 조각에 배경을 제공해야합니다. backgroind에 레이아웃의 배경에 배경을 설정합니다.

0

이 코드 섹션을 사용해보십시오. 필요한 경우 애니메이션을 만듭니다.

public static void callFragment(Fragment fragment, Context context, String TAG) { 
    FragmentManager fragmentManager = ((AppCompatActivity) context).getSupportFragmentManager(); 
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); 
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN); 
    if (fragment.isAdded()) { 
     fragmentTransaction.show(fragment); 
    } else { 
     // fragmentTransaction.setCustomAnimations(R.anim.fade_in, R.anim.face_out); 
     fragmentTransaction.setCustomAnimations(R.anim.fragment_slide_top_enter, R.anim.fragment_slide_top_exit, R.anim.fragment_slide_bottom_enter, R.anim.fragment_slide_bottom_exit); 
     fragmentTransaction.replace(R.id.content_frame, fragment); 
     fragmentTransaction.addToBackStack(TAG); 
    } 
    fragmentTransaction.commit(); 
} 

또한 조각 레이아웃 파일의 배경 정보를 제공합니다.