Android 导航视图高度我已设置为与父项匹配,但它不匹配';我一点也不像你的父母
我已将导航视图高度设置为与父视图匹配,但它与父视图完全不匹配 以下是xml代码:Android 导航视图高度我已设置为与父项匹配,但它不匹配';我一点也不像你的父母,android,xml,drawerlayout,navigation-drawer,android-navigationview,Android,Xml,Drawerlayout,Navigation Drawer,Android Navigationview,我已将导航视图高度设置为与父视图匹配,但它与父视图完全不匹配 以下是xml代码: <?xml version="1.0" encoding="utf-8"?> <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:too
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/content">
</FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/moveimage"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@drawable/ic_launcher"/>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
android:background="#fff"
app:headerLayout="@layout/nav_header" />
</android.support.v4.widget.DrawerLayout>
请尝试以下内容,可能会对您有所帮助:
相对布局没有方向attribute@Yasharyan什么是方向属性?我应该更改什么?您有两个相对布局。第一个是行android:orientation=“vertical”
。移除它。请注意,如果这修复了任何问题,但这是一种不正确的做法。@Yasharyan已将其删除,但它不会像您一样修复任何问题said@TommyChong:第二次相对布局的目的是什么?是否要在NavigationView中添加?
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/lytMain"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/side_nav_bar">
<ImageView
android:id="@+id/moveimage"
android:layout_width="50dp"
android:layout_height="50dp"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"/>