如何在抽屉布局上方添加视图?

用户782104

http://developer.android.com/design/patterns/navigation-drawer.html

我正在研究导航抽屉。该代码建议我使用如下所示的导航抽屉:

<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">
    <!-- The main content view -->
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <!-- The navigation drawer -->
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        android:background="#111"/>
</android.support.v4.widget.DrawerLayout>

framelayout将存储片段,而left_drawer是左侧菜单,问题是,我想在left_drawer和framelayout之间添加一个视图

left_drawer on top of my view , my view on top of framelayout如何实现这样的布局?还是我需要将视图添加到每个片段?

谢谢

更新:

<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" >

    <!--
         As the main content view, the view below consumes the entire
         space available using match_parent in both dimensions.
    -->

    <FrameLayout
        android:id="@+id/content_frame"
        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.
         The drawer is given a fixed width in dp and extends the full height of
         the container. A solid background is used for contrast
         with the content view.
    -->

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/bottomMenu1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_1"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/bottomMenu2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_2"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/bottomMenu3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_3"
            android:textColor="#ffffff"
            android:textSize="20sp" />

        <TextView
            android:id="@+id/bottomMenu4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:background="@color/bottom_menu_unchecked"
            android:gravity="center"
            android:text="@string/bottom_menu_4"
            android:textColor="#ffffff"
            android:textSize="20sp" />
    </LinearLayout>

    <ListView
        android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="0dip"
        android:layout_gravity="start"
        android:layout_weight="1"
        android:background="#111"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp" />

</android.support.v4.widget.DrawerLayout>
医学博士

将View放在ListView上方,并将其包装在垂直的LinearLayout中。给您的ListView android:layout_weight =“ 1”和android:layout_height =“ 0dip”

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

导航抽屉如何在列表视图上方添加图像视图

如何在其父级布局上方绘制视图?

如何在导航抽屉布局中添加图像标题

如何在材料抽屉布局中添加字幕?

如何在Android视图上方添加阴影

如何在相对布局或任何布局中动态添加视图

如何以编程方式添加自动布局约束以使按钮在其视图底部上方50点?

如何在抽屉式布局中使用普通Listview实现可扩展列表视图?

如何在抽屉布局的导航视图中设置这些彩色图标

将视图放在DrawerLayout上方(抽屉上方)

如何在android布局视图中添加或替换页面

如何在表格布局中添加滚动视图?

如何在卡片视图中添加布局?

如何在反应导航中使抽屉位于标题上方?

如何使用回收站视图定制抽屉布局?

如何在UICollectionView上方实现内容视图

如何在已添加到keyWindow的视图上方显示模态?

如何在Android Studio中的Sticky Header RecyclerView上方添加固定视图?

如何设置文本以从导航抽屉中的抽屉标题布局查看而不会放大视图

如何在导航抽屉上添加图标?

Android在抽屉式布局的列表视图的底部添加文本视图

如何在 recyclerview 中添加页脚视图,该视图从 DB 和反向布局中获取数据

如何在选项卡栏上方底部的所有视图控制器中添加通用视图

如何在圆圈上方添加文字?

如何在图片上方添加文字?

如何在按钮上方添加徽章?

如何在隐藏的 <div> 上方添加 <div>

如何在列表上方添加按钮?

如何在createMaterialTopTabNavigator上方添加组件?