Android 是否有人知道如何更改布局xml以使工具栏不';不包括这些项目吗?

Android 是否有人知道如何更改布局xml以使工具栏不';不包括这些项目吗?,android,android-layout,android-recyclerview,android-emulator,android-toolbar,Android,Android Layout,Android Recyclerview,Android Emulator,Android Toolbar,谢谢 这里是主要的xml: 不要硬编码RecyclerView高度,只需使用ConstraintLayout作为根布局,并将RecyclerView的顶部约束到AppBarLayout的底部即可。由于您没有附加任何有关您希望布局如何的图像,我假设您的要求是: AppBarLayout带有包含标题“电子时间资本”的工具栏 在工具栏下方的布局内容\u main 布局内容\u主视图下方的回收视图 右下角的浮动操作按钮 <androidx.constraintlayout.widget.

谢谢

这里是主要的xml:



不要硬编码RecyclerView高度,只需使用ConstraintLayout作为根布局,并将RecyclerView的顶部约束到AppBarLayout的底部即可。

由于您没有附加任何有关您希望布局如何的图像,我假设您的要求是:

  • AppBarLayout带有包含标题“电子时间资本”的工具栏

  • 工具栏下方的布局内容\u main

  • 布局内容\u主视图下方的回收视图

  • 右下角的浮动操作按钮

     <androidx.constraintlayout.widget.ConstraintLayout 
         xmlns:android="http://schemas.android.com/apk/res/android"
         xmlns:app="http://schemas.android.com/apk/res-auto"
         android:layout_width="match_parent"
         android:layout_height="match_parent">
    
         <com.google.android.material.appbar.AppBarLayout
             android:id="@+id/appBarLayout"
             android:layout_width="match_parent"
             android:layout_height="wrap_content"
             android:theme="@style/AppTheme.AppBarOverlay"
             app:layout_constraintTop_toTopOf="parent">
    
             <androidx.appcompat.widget.Toolbar
                 android:id="@+id/toolbar"
                 android:layout_width="match_parent"
                 android:layout_height="?attr/actionBarSize"
                 android:background="#EFC6D4"
                 app:popupTheme="@style/AppTheme.PopupOverlay">
    
                 <TextView
                     android:id="@+id/textView"
                     android:layout_width="wrap_content"
                     android:layout_height="wrap_content"
                     android:text="@string/electric_time_capital"
                     android:textAppearance="@style/TextAppearance.AppCompat.Large"
                     android:textColor="#FFFFFF" />
             </androidx.appcompat.widget.Toolbar>
    
         </com.google.android.material.appbar.AppBarLayout>
    
         <include
             android:id="@+id/include"
             layout="@layout/content_main"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             app:layout_constraintTop_toBottomOf="@id/appBarLayout" />
    
         <com.google.android.material.floatingactionbutton.FloatingActionButton
             android:id="@+id/fab"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_gravity="bottom|end"
             android:layout_margin="@dimen/fab_margin"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintRight_toRightOf="parent"
             app:srcCompat="@android:drawable/ic_dialog_email" />
    
         <androidx.recyclerview.widget.RecyclerView
             android:id="@+id/recyclerview"
             android:layout_width="match_parent"
             android:layout_height="669dp"
             android:layout_below="@id/include"
             app:layout_constraintTop_toBottomOf="@id/include" /> 
     </androidx.constraintlayout.widget.ConstraintLayout>
    
    因为更容易做出响应
    布局。当您第一次使用它时,它可能看起来很棘手,但它是
    最好的方法

    快乐编码!