我有一个带有RecyclerView的片段,可以显示项目。当我点击一个项目时,会实例化一个新的片段:
public void onItemClick(View view, int position) {
getActivity().getSupportFragmentManager().beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
.add(R.id.detail_container, new DetailFragment())
.addToBackStack(null)
.commit();
selected_item = position;
}
并添加到黑色背景的容器中:
<FrameLayout
android:id="@+id/detail_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="30dp"
android:background="@android:color/black" />