简体   繁体   English

如何在LinearLayout中使用片段

[英]How to use fragments with LinearLayout

I'm doing a Android App and I'm having problem when I use LinearLayout in my FragmentActivity with some fragments. 我正在做一个Android应用,当我在FragmentActivity中使用LinearLayout并带有一些片段时遇到了问题。

In the XML of my FragmentActivity I'm using LinearLayout with vertical orientation. 在我的FragmentActivity的XML中,我使用的是垂直方向的LinearLayout。 On the onCreate method I add 3 fragments on this activity. 在onCreate方法上,我在此活动上添加了3个片段。 But it show only the first fragment. 但它只显示第一个片段。

If I change LinearLayout to FrameLayout all the fragments are show overlapping each other 如果我将LinearLayout更改为FrameLayout,则所有片段都显示为相互重叠

@Daniel Gabay is right. @Daniel Gabay是正确的。 The problem was caused because I was using the wrong value for android:layout_width,android:layout_height 造成此问题的原因是我为android:layout_width,android:layout_height使用了错误的值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM