在这种情况下我该怎么办?

时间:2015-12-30 04:58:39

标签: android fragment

我有这样的antwo片段: enter image description here

我想要的是当我按下" MapView"按钮,整个屏幕将是这样的: enter image description here

那么在这种情况下我应该做些什么才能拥有最好的用户体验?我应该关闭两个片段并添加一个新片段吗?请给我一些想法!谢谢!

3 个答案:

答案 0 :(得分:2)

最好将整个内容转换为4个片段。

片段1:搜索栏

片段2:两个按钮

片段3:底部列表

片段4:地图

因此,在这种情况下,您可以听取单击每个按钮并将具有片段3的相应容器替换为片段4.如果您的设计需要隐藏片段1,则在这种情况下也可以完成。

答案 1 :(得分:0)

您需要一个父布局,顶部有两个按钮。 MapView和列表视图。然后通过java代码点击按钮显示所需的片段

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:orientation="vertical" >
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="MapView" />
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:hint="ListView" />
 <fragment
 android:name="com.example.app.myFragment"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 tools:layout="@layout/my_fragment" 
 />
 </LinearLayout>

答案 2 :(得分:0)

我建议使用PagerTitleStrip布局。只需用片段事务替换标题条下面的内容即可。如果您需要更多信息(如何设置),请随时询问。 一个很好的起点是docsguidelines,也许是tutorial

顺便说一下:我的一个应用程序做了类似的工作,看看:Libre Drive

相关问题