quarta-feira, 17 de abril de 2019

Como mudar a cor do FloatingActionButton

Change Floating Action Button color


No XML:
app:backgroundTint="@color/colorAccent"
No código:
setBackgroundTintList(ColorStateList.valueOf(
     getResources().getColor(R.color.colorAccent))
)

Como mostrar uma mensagem de lista vazia em um RecyclerView no Android?

// Adicionando mensagem lista vazia
<android.support.v7.widget.RecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="vertical" />

<TextView
    android:id="@+id/messege_empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:visibility="gone"
    android:text="@string/no_itens" />

private RecyclerView recyclerView;
private TextView emptyMessege;

// ...

recyclerView = findViewById(R.id.recycler_view);
emptyMessege = findViewById(R.id.messege_empty);
// ...

if (adapterList.isEmpty()) {
    recyclerView.setVisibility(View.GONE);
    emptyMessege.setVisibility(View.VISIBLE);}
else {
    recyclerView.setVisibility(View.VISIBLE);
    emptyMessege.setVisibility(View.GONE);}