【问题标题】:Dealing with Android Navigation处理 Android 导航
【发布时间】:2014-02-28 16:42:00
【问题描述】:

我正在为我的应用寻找一些关于导航的指针/建议/等。以下是我所有屏幕的布局以及它们之间的流程:

所以这个布局的主要部分我很难理解如何实现是最左边的导航抽屉按钮的孩子。按钮下方的主屏幕实际上只是另一个带有按钮的屏幕,当单击 Main 上的按钮时,它会像一组屏幕一样带您进入向导。在每个步骤中,您都可以返回上一个屏幕,前进到下一个屏幕,或者通过单击抽屉按钮,您将再次回到主屏幕。

所以我怀疑,这是来自一个对 android 几乎全新的人,我需要一个 main 活动,然后一个活动,每个步骤都有一组片段,对吗?任何建议都是有用的。

【问题讨论】:

    标签: android android-activity navigation fragment


    【解决方案1】:

    使用 DrawerLayout 和像这样的片段:

    <?xml version="1.0" encoding="utf-8"?>
    <android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    
    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >
    
        <fragment
            android:id="@+id/mainFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:name="MainFragment" />
    
    </RelativeLayout>
    
    
    <!-- The navigation drawer -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="200dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="#FF232323"
        android:layout_marginTop="64dp"
        >
        <fragment
            android:id="@+id/navigation"
            android:name="NavigationFragment"
            android:layout_height="match_parent"
            android:layout_width="wrap_content" />
    
    </FrameLayout>
    

    【讨论】:

    • 太棒了!那么主要到各个步骤屏幕呢?所有这些步骤屏幕都应该是一个分解成多个片段的活动吗?
    • Go read this。文档中的示例很好地解释了
    猜你喜欢
    • 2019-12-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多