Exo*_*Kid 10 android android-layout android-toolbar
我需要这个xml布局的帮助,因为我Fragment在工具栏下面.
我尝试了各种各样的布局属性layout_below,但没有成功.也在NavigationView工具栏下面.
该ConstraintLayout像app:layout_constraintTop_toTopOf没有任何影响,如果我做的容器ConstraintLayout
这是我的xml希望得到一些建议?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:autofit="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.port.android.ui.ActivityMain">
<android.support.design.widget.AppBarLayout
android:id="@+id/appBarLayout_1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary">
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.port.android.ui.ActivityMain">
<android.support.constraint.ConstraintLayout
android:id="@+id/main_ConstraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="@+id/frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</FrameLayout>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
<android.support.design.widget.NavigationView
android:id="@+id/navigation_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:layout_marginBottom="15dp"
android:layout_marginTop="15dp"
app:headerLayout="@layout/navigation_view_header"
app:menu="@menu/menu_navigation">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:padding="20dp">
<Button
android:id="@+id/btn_exit_address"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="exitAddress"
android:text="@string/exit_address" />
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
对于像我这样最终会为这个问题寻找答案的人。
我修正了使用方式<ConstraintLayout>,改变孩子<FrameLayout> layout_height,并layout_width给"0dp"它等于“MATCH_CONSTRAINT”。此外,您还应该添加一些约束属性,如下所示。
你<FrameLayout>应该是这样的:
<FrameLayout
android:id="@+id/fragment_placeholder"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/main_toolbar"
app:layout_constraintBottom_toTopOf="@id/navigation"
/>
Run Code Online (Sandbox Code Playgroud)
我希望它有帮助!
小智 5
在您的抽屉布局中尝试以下布局
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.port.android.ui.ActivityMain"
android:layout_below="@+id/appBarLayout_1">
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2230 次 |
| 最近记录: |