Search code examples
androidxmlfloating-action-button

floating action button not showing image


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': ' enter image description here

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"/>

Solution

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

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