这是问题所在 我有一个水平片段列表,我想将它们添加到framelayout并像列表一样显示它们。但是它们相互重叠。我应该为每个片段使用一个framelayout吗?或者有什么技巧吗?
XML代码
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- android:layout_gravity="start" tells DrawerLayout to treat
this as a sliding drawer on the left side for left-to-right
languages and on the right side for right-to-left languages.
If you're not building against API 17 or higher, use
android:layout_gravity="left" instead. -->
<!-- The drawer is given a fixed width in dp and extends the full height of
the container. -->
<fragment
android:id="@+id/navigation_drawer"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:name="com.fujixerox.internaljobrecord.NavigationDrawerFragment"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
Java代码
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
//Add the newFragment to fragmentContainer
fragmentTransaction.add(R.id.container, nameFrag);
fragmentTransaction.add(R.id.container, jobTypeFrag);
fragmentTransaction.add(R.id.container, productFrag);
fragmentTransaction.add(R.id.container, configFrag);
fragmentTransaction.add(R.id.container, serialFrag);
fragmentTransaction.add(R.id.container, CATFrag);
fragmentTransaction.add(R.id.container, outgoingFrag);
fragmentTransaction.add(R.id.container, oldMeterFrag);
fragmentTransaction.add(R.id.container, newMeterFrag);
fragmentTransaction.add(R.id.container, refTimeFrag);
fragmentTransaction.add(R.id.container, totalTimeFrag);
fragmentTransaction.add(R.id.container, buttonFrag);
fragmentTransaction.commit();
答案 0 :(得分:0)
我建议您将此库用于水平ListView,您可以根据需要将其ListItem重写为片段: