3
respostas

Mover floatingbutton

Ao mover o floatingButton o android devolver ao canto superior esquerdo, mesmo convertendo a View para Relative. O que poderia causar este tipo de situação?

3 respostas

Oi Wagner, tudo bem ?

Cara consegue mostrar pra gente como está o seu xml ? Assim a gente consegue ver o motivo pra te ajudar

Segue

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.google.android.material.floatingactionbutton.FloatingActionButton
        android:id="@+id/floatingActionButton3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:clickable="true"
        android:focusable="true"
        app:srcCompat="@mipmap/ic_launcher_round" />

    <ListView
        android:id="@+id/activity_main_lista_aluno"
        android:layout_width="395dp"
        android:layout_height="527dp">

    </ListView>
</RelativeLayout>

<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:id="@+id/relativeLayout" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".ui.activity.ListaAlunosActivity">

<com.google.android.material.floatingactionbutton.FloatingActionButton
    android:id="@+id/activity_lista_alunos_fab_novo_aluno"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginEnd="26dp"
    android:layout_marginBottom="26dp"
    android:clickable="true"
    android:src="@drawable/ic_action_novo_aluno"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    android:focusable="true" />

<ListView
    android:id="@+id/activity_lista_alunos_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginStart="1dp"
    android:layout_marginTop="1dp"
    android:layout_marginEnd="1dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent">

</ListView>

</androidx.constraintlayout.widget.ConstraintLayout>

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software