【发布时间】:2015-06-01 09:29:43
【问题描述】:
我在this 之后实现了抽屉式导航。添加我的 xml 后,活动未在中心位置显示 imageview。 以下是我的xml文件
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#2ba886"
app:contentInsetEnd="0dp"
app:contentInsetStart="0dp" >
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawerLayout"
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" >
<!-- <RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" > -->
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/logo_img"
/>
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:background="#fff" >
<ListView
android:id="@+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:divider="#eee"
android:dividerHeight="1dp" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
问题是 Imageview layout_gravity 选项没有出现 请帮忙。。
【问题讨论】:
-
ImageView 默认对齐到 FrameLayout 的左上角。此外,您应该有一个精确的度量 - 例如
240dp- 用于抽屉的RelativeLayout 的layout_width。 -
@MikeM。如何在活动视图的导航抽屉下方显示不同的视图(例如按钮、文本视图、编辑文本)
-
“下面”是什么意思?朝向屏幕底部?还是在抽屉后面按 z 顺序排列?
-
@MikeM。参考我附加的图像..在 xml 中添加按钮和图像视图的位置
-
如果您的意思是要将它们放在抽屉后面的灰色区域中,您可以将它们放在 FrameLayout 中。不过,FrameLayouts 并不是真的要灵活地容纳多个孩子,因此您可以更改它,或者在其中嵌套另一种类型的 ViewGroup。
标签: android android-layout navigation drawer