显示导航抽屉的进度

时间:2014-12-05 16:31:48

标签: android navigation-drawer

我想在Navigation Drawer上运行这样的进展:

enter image description here

我已成功创建了导航抽屉,但不知道如何制作这样的进度条。可能吗 ?我真的很感激任何回复。

1 个答案:

答案 0 :(得分:3)

如果您已成功创建导航抽屉,则必须具有布局。只需在ProgressBar为(ListView的第二个孩子)的布局中添加DrawerLayout即可。您可以在setContentView之后通过findViewById初始化并使用它。

<?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"
    >
    <FrameLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        />
    <LinearLayout
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:gravity="start"
        >
        <ListView
            android:id="@+id/myList"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            />
        <ProgressBar
            android:id="@+id/myProgress"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_margin="16dp"
            android:progress="40"
            />
    </LinearLayout>
</android.support.v4.widget.DrawerLayout>

如果您想滚动它,则必须创建一个适配器,其中一个itemTypes是ProgressBar

如果您只是想知道如何制作水平进度条:read this