【问题标题】:navigation drawer how to add image view above list view导航抽屉如何在列表视图上方添加图像视图
【发布时间】:2015-03-03 10:04:40
【问题描述】:

我正在开发需要导航抽屉的应用程序。我使用谷歌的代码开发导航抽屉

<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <!-- Framelayout to display Fragments -->

    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <!-- Listview to display slider menu -->

    <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:background="#6495ED"
        android:choiceMode="singleChoice"
        android:divider="@color/list_divider"
        android:dividerHeight="1dp"
        android:listSelector="#fff" />

</android.support.v4.widget.DrawerLayout>

通过这个我得到一个导航抽屉,但我想在列表视图上方放置一个图像视图。我用谷歌搜索了它,但我没有得到我的手段

【问题讨论】:

  • 你能给我们看一个你想要什么的例子吗?
  • 可以在ListView中添加headerView
  • @Skizo 我想设计一个导航抽屉,我想在其中显示用户图像和名称,然后是列表视图 .. 我知道如何显示列表视图但不知道如何添加图像视图和文本视图在导航抽屉中。我已经在上面显示了关于我从谷歌开发者网站获取的导航抽屉的代码。
  • @virendrao 通过这个问题不会解决兄弟.. bcz 将只显示标题到列表视图
  • 为什么不能解决请详细说明...您可以制作自定义列表视图。

标签: android listview navigation imageview drawer


【解决方案1】:

我们可以通过这个添加一个 HeaderView 到列表中,userImage 会像这样出现在 listView 之上 ViewGroup header = (ViewGroup) inflater.inflate(R.layout.headerview, mDrawerList,false);

    mDrawerList.addHeaderView(header, null, false);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多