簡體   English   中英

更改mainactivity中片段的布局

[英]change layout of fragment in mainactivity

當我單擊按鈕時,我可以刪除一個片段,而我還有2個其他片段,其中一個已刪除,我想要的是當第一個片段被刪除時,另外兩個片段填補了由刪除的片段引起的空白。

在此處輸入圖片說明

當我單擊按鈕時,它被刪除:

在此處輸入圖片說明

但是有空白空間,我希望兩個片段正確填充空白空間

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> 

將f1容器刪除后將其設置為visible = gone

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM