Я пытаюсь построить панель навигации с кнопками чуть ниже «списка» элементов, которые он показывает из папки меню. Я пытался добавить linearLayout под ним, но он просто не позволял мне использовать «свободное» пространство. высота NavigationView равна «wrap_content».
основная деятельность:
<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 = "end">
<include
layout = "@layout/app_bar_main"
android:layout_width = "match_parent"
android:layout_height = "match_parent" />
<android.support.design.widget.NavigationView
android:id = "@+id/nav_view"
android:theme = "@style/NavStyle"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:layout_gravity = "end"
android:layoutDirection = "rtl"
android:fitsSystemWindows = "false"
app:itemTextColor = "@color/white"
app:itemIconTint = "@color/white"
app:headerLayout = "@layout/nav_header_main"
android:background = "@drawable/background_menu_bar"
app:menu = "@menu/activity_main_drawer"
>
<LinearLayout
android:layout_width = "match_parent"
android:layout_height = "match_parent"
android:orientation = "vertical"
android:gravity = "center_horizontal"
>
<Button
android:id = "@+id/android_rules_button"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:background = "@color/light_gray"
android:textColor = "@color/black"
android:text = "תקנון החברה"
android:textSize = "15dp"
android:layout_marginTop = "250dp"
android:layout_marginStart = "32dp"
android:layout_marginEnd = "32dp"/>
<Button
android:id = "@+id/android1_about_button"
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:background = "@color/light_gray"
android:textColor = "@color/black"
android:text = "אודותינו"
android:textSize = "15dp"
android:layout_marginTop = "266dp"
android:layout_marginStart = "32dp"
android:layout_marginEnd = "32dp"/>
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
вот как это должно выглядеть:
Спасибо!
В этом случае вы должны использовать относительный макет для кнопок.
<RelativeLayout android: layout_width = "match_parent" android: layout_height = "match_parent" android: direction = "vertical" android: gravity = "center_horizontal"> <Button android: id = "@ + id / android_rules_button" ... /> < Кнопка android: id = "@ + id / android1_about_button" ... android: layout_below = "@ + id / android_rules_button" /> </RelativeLayout>
Где мне использовать относительный макет? Я попытался изменить на него линейную компоновку, но все равно ничего не вышло.