【发布时间】:2019-04-26 07:59:41
【问题描述】:
我试图在屏幕右下角有一个 FAB 以浮动在 recyclerview 的顶部。然而,FAB 只是一个带有小部件路径的灰色框。
问题来了:
<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'
}
【问题讨论】:
-
你添加设计依赖了吗?
-
是的。检查编辑。
-
您是否在其中插入了任何可绘制对象?我没有看到任何与之相关的可绘制对象。
标签: android android-layout android-recyclerview floating-action-button