Ich kann ein Fragment löschen, wenn ich auf eine Schaltfläche klicke, und ich habe 2 andere Fragmente mit der gelöschten, was ich will ist, wenn das erste Fragment gelöscht wird, füllen die beiden anderen den leeren Raum verursacht durch das gelöschte Fragment.Layout des Fragments in Mainactivity ändern
und wenn ich auf eine Schaltfläche klicken, wird sie gelöscht:
aber es ist leerer Raum, möchte ich die beiden Fragmente den leeren Raum
richtig füllen Activity_main_Layout.xml
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
>
<FrameLayout
android:layout_width="87dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:id="@+id/frml"></FrameLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.pack2.t9ahbin.MainActivity"
android:orientation="vertical"
android:id="@+id/linear"
>
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.example.pack2.t9ahbin.FragA"
android:id="@+id/fragment"
android:layout_weight="1"
/>
<fragment
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:name="com.example.pack2.t9ahbin.fragB"
android:id="@+id/fragment2"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
Bearbeiten Sie Ihre Frage entfernen Sie die übergeordnete Aktivität Layout –