Android fragments overlap

前端 未结 1 760
忘了有多久
忘了有多久 2021-01-28 23:57

I have an activity with two fragments, one to display a list and one to show the details of the clicked item. When starting the app the detail part is something static, once I c

相关标签:
1条回答
  • 2021-01-29 00:52

    Instead of using in layout xml fragment:

    <fragment
        android:id="@+id/detailFragment"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2"
        class="com.fragments.FragmentOrderDetails" >
    
    </fragment>
    

    Use some container like LinearLayout or FrameLayout with some containerId. Then programatically firstly add fragment to this container using containerId, and after that replace content of this container with containerId also.

    0 讨论(0)
提交回复
热议问题