Java BottomAppBar背景与父项不正确匹配,并显示在屏幕的一半
我尝试了我的布局代码,但底部的AppBar并没有完美地显示出来。我到处搜索,但没有发现任何问题 我在Android Studio 3.4上试过这个,我的gradle依赖项是Java BottomAppBar背景与父项不正确匹配,并显示在屏幕的一半,java,android,android-bottomappbar,Java,Android,Android Bottomappbar,我尝试了我的布局代码,但底部的AppBar并没有完美地显示出来。我到处搜索,但没有发现任何问题 我在Android Studio 3.4上试过这个,我的gradle依赖项是 dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) //noinspection GradleCompatible implementation 'com.google.android.material:ma
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
//noinspection GradleCompatible
implementation 'com.google.android.material:material:1.0.0-beta01'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
implementation 'androidx.vectordrawable:vectordrawable:1.0.0-beta01'
implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.squareup.picasso:picasso:2.71828'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation 'com.github.bumptech.glide:glide:4.9.0'
}
我在home\u bottomappbar.xml中使用的代码
<androidx.coordinatorlayout.widget.CoordinatorLayout
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:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.material.bottomappbar.BottomAppBar
android:id="@+id/bottom_app_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_gravity="bottom"
app:backgroundTint="@color/colorPrimaryDark"
app:fabAlignmentMode="center"
app:fabAttached="true"
app:fabCradleDiameter="0dp"
app:fabCradleVerticalOffset="10dp" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="@id/bottom_app_bar"
app:backgroundTint="@color/colorPrimary"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
将协调器
布局替换为相对
或线性
布局。它可以正常工作。用Relative
或Liner
布局替换协调器
布局。它会很好用的。我也曾经有过同样的问题
解决方法是将底部AppBar的宽度更改为填充父对象,现在应该可以正常工作:)我也有一段时间遇到同样的问题
解决方案是将底部AppBar的宽度更改为填充父对象,现在应该可以正常工作:)如果出现渲染问题,可以添加屏幕截图,这将有助于合作者在不阅读整篇文章的情况下理解问题。感谢您的回答,我添加了Screeshot链接。请检查它。如果存在渲染问题,您可以添加屏幕截图,这将帮助合作者理解问题,而无需阅读整篇文章。感谢您的回答,我添加了Screeshot链接。请检查它的线性布局或相关也不工作。我不知道为什么该代码在这个项目中不起作用。它在我的其他项目中工作得非常好。如果在嵌套布局中使用
协调器
布局,您的协调器
布局应该是父/根布局,并设置布局锚定。LinearLayout或relative也不工作。我不知道为什么该代码在这个项目中不起作用。它在我的另一个项目中工作得非常好。如果在嵌套布局中使用协调器
布局,则您的协调器
布局应该是父/根布局并设置布局定位。