floating action button not showing image [duplicate]

感情迁移 提交于 2021-01-29 14:10:23

问题


I've added xml code to have a floating action button on my screen (no functionality right now but will) but when I go onto the design view of xml, instead of showing the email icon image, it shows just text like 'floating action button': '

Could someone explain what I've done wrong?

the code I use:

    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@android:drawable/ic_dialog_email"
        android:layout_gravity="bottom|end"
        app:elevation="6dp"
        app:pressedTranslationZ="12dp"/>

回答1:


It means the correct library is not added. Try adding design library

implementation 'com.android.support:design:27.1.1'


来源:https://stackoverflow.com/questions/51739465/floating-action-button-not-showing-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!