Есть такой XML layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:id="@+id/fragment1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<fragment
android:name="autovesti.auto.Fragment2"
android:id="@+id/fragment2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
</fragment>
</FrameLayout>
Как правильно заменить fragment 1 на fragment 2? Вот так
tran = getFragmentManager().beginTransaction();
tran.replace(R.id.fragment1, new Fragment2());
Первый становится прозрачным, и появляется второй.