本文介绍了浮动操作按钮显示为灰色框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在屏幕的右下角放置一个FAB,使其漂浮在 recyclerview
的顶部.但是,FAB只是带有小部件路径的灰色框.
I'm trying to have a FAB at the bottom-right corner of my screen to float on top of the recyclerview
. However, the FAB is just a gray box with the widget's path.
问题出在这里
这是我的XML实现:
This is my XML implementation:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/userpass_recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/generate_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="16dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:clickable="true"
android:focusable="true" />
</RelativeLayout>
依赖项:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.android.support:design:28.0.1'
implementation 'com.google.android.material:material:1.1.0-alpha05'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}
推荐答案
尝试 file>使缓存/重启无效
.这就是我的一些小部件变成灰色的问题.
Try file>invalidate caches/restart
. That's the issue I had with some of my widgets that were greyed out.
这篇关于浮动操作按钮显示为灰色框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!