Android 如何在导航抽屉下方显示我的布局?
我已经实现了以下导航抽屉。在添加my xml后,“活动”不会在中间位置显示imageview。 下面是我的xml文件Android 如何在导航抽屉下方显示我的布局?,android,android-layout,navigation,drawer,Android,Android Layout,Navigation,Drawer,我已经实现了以下导航抽屉。在添加my xml后,“活动”不会在中间位置显示imageview。 下面是我的xml文件 问题是Imageview布局\重力选项不可用 请帮忙 试试这个:在linearlayoue中拍摄图像并设置重力 <FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height
问题是Imageview布局\重力选项不可用
请帮忙 试试这个:在linearlayoue中拍摄图像并设置重力
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" > -->
<LinearLayout android:id="@+id/..."
android:layout_width="..."
android:layout_height="fill_parent"
android:layout_gravity="start"
android:orientation="vertical"
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/logo_img"
/>
</Linearlayout>
</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" >
<!-- Framelayout to display Fragments -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="@layout/actionbar" />
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>
<!-- Listview to display slider menu -->
<LinearLayout
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Home"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Android"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Sitemap"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="About"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Contact Me"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button2" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button3" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
删除列表视图并设置抽屉项目手动单击 默认情况下,ImageView将与FrameLayout的左上角对齐。此外,您还应该有一个精确的测量值,例如抽屉相对长度的布局宽度。@MikeM。如何在活动视图的导航抽屉下方显示不同的视图(例如按钮、文本视图、编辑文本)您所说的“下方”是什么意思?朝向屏幕底部?还是抽屉后面的z-Order?@MikeM。参考我所附的图片..在XML中添加按钮和imageview的位置如果你想将它们放在抽屉后面的灰色区域,你应该将它们放在FrameLayout中。不过,框架布局实际上并不意味着可以灵活地容纳多个子视图,因此您可以对其进行更改,或者在其中嵌套另一种类型的视图组。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_above="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<!-- The main content view -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<!-- The navigation drawer -->
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#555555"
android:choiceMode="singleChoice"
android:divider="#666"
android:dividerHeight="1dp" />
</android.support.v4.widget.DrawerLayout>
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="0dp"
android:orientation="horizontal" >
<include layout="@layout/tab_bar" />
</LinearLayout>
</RelativeLayout>
<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 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="@layout/actionbar" />
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</FrameLayout>
</LinearLayout>
<!-- Listview to display slider menu -->
<LinearLayout
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@android:color/white"
android:orientation="vertical" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Home"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Android"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Sitemap"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="About"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
android:text="Contact Me"
android:textColor="@android:color/black"
android:textSize="20sp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:padding="10dp"
android:src="@drawable/ic_launcher" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@android:color/black" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button2" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button3" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>