Cześć
Próbuje zrobić pływający przycisk (FloatingActionButton) próbowałem doradzać się ChatGPT i googla ale na niewiele się to zdało
I proszę was o pomoc w zrobieniu tego przycisku.
Znalazłem takie sposoby na stworzenie tego przycisku, ale wolał bym to zrobić dedykowanym przyciskiem, jeśli to możliwe?
Pierwszy sposoób:
- File > New > Image Asset - niestety przy dłuższych tekstach tekst staje się mało czytelny
Drugi sposób:
- Dodałem bibliotekę
implementation 'com.google.android.material:material:1.4.0'
I wpisałem kod:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:text="Tekst na przycisku" />
niestety nie działa
Trzeci sposób:
- Ten sposób działa ale to jednak nie bezpośrednio przycisk pływający
<?xml version="1.0" encoding="utf-8"?> <androidx.constraintlayout.widget.ConstraintLayout 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" tools:context=".MainActivity"> <FrameLayout android:layout_width="match_parent" android:layout_height="match_parent"> <Button android:id="@+id/button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /> </FrameLayout> </androidx.constraintlayout.widget.ConstraintLayout>