我怎样才能像这样渲染屏幕

时间:2016-04-16 07:56:18

标签: android android-layout android-fragments xamarin xamarin.android

This is the screen i have to render

当我尝试运行此代码时,列表项1与主工具栏按钮重叠。我尝试过很多方法,但一次又一次地遇到同样的问题。我想将我的屏幕显示为上图。在这里,我也提供我的代码。请建议我。

先谢谢。

<android.support.v4.widget.DrawerLayout        xmlns:android="http://schemas.android.com/apk/res/android"
         android:orientation="vertical"
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         android:background="#FFFFFF"
         android:id="@+id/sample_main_layout">  
            <ImageButton
                android:src="@drawable/ic_action_new"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentLeft="true"
                 android:adjustViewBounds="true"
                android:layout_weight="1"
                android:id="@+id/New"
                android:tag="-9999" />
            <ImageButton
                android:src="@drawable/ic_view_module"
                 android:adjustViewBounds="true"
                android:layout_weight="1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_toRightOf="@id/New"
                android:id="@+id/All"
                android:tag="-1" />               

              <FrameLayout
              android:id="@+id/sample_content_fragment"
              android:layout_weight="2"
              android:layout_width="match_parent"
              android:layout_height="0px">
              </FrameLayout>          
          <ListView
                    android:id="@+id/left_drawer"
                    android:layout_width="240dp"
                    android:layout_height="match_parent"
                    android:layout_gravity="left"
                    android:choiceMode="singleChoice"
                    android:divider="@android:color/transparent"
                    android:dividerHeight="0dp"
                    android:background="#dedede" />
</android.support.v4.widget.DrawerLay>

1 个答案:

答案 0 :(得分:0)

我不确定您是否尝试在主视图上呈现ButtonDrawerLayout将覆盖视图的整个高度。

抽屉关闭:

enter image description here

抽屉打开:

enter image description here

<?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_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <FrameLayout
        android:id="@+id/content_frame"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >
        <ImageButton
            android:src="@drawable/Icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
             android:adjustViewBounds="true"
            android:layout_weight="1"
            android:id="@+id/First"
            android:tag="-3" />
        <ImageButton
            android:src="@drawable/Icon"
             android:adjustViewBounds="true"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/First"
            android:id="@+id/Second"
            android:tag="-2" />   
        <ImageButton
            android:src="@drawable/Icon"
             android:adjustViewBounds="true"
            android:layout_weight="1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_toRightOf="@id/Second"
            android:id="@+id/Third"
            android:tag="-1" />
    </LinearLayout>
    <ListView android:id="@+id/left_drawer"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="left"
        android:choiceMode="singleChoice"
        android:divider="@android:color/transparent"
        android:dividerHeight="0dp"
        />
</android.support.v4.widget.DrawerLayout>
相关问题