Aprovecha el precio especial

Antes:$249

Currency
$209

Paga en 4 cuotas sin intereses

Paga en 4 cuotas sin intereses
Comienza ahora

Termina en:

02d

07h

21m

27s

2

Nuevo estilo a BottomNavigationView

¡Adiós BottomBar!

  • Para poder usar este widget, es necesario que incluyas las librerías de soporte de diseño y compatibilidad:
dependencies {
    implementation 'com.android.support:appcompat-v7:X.X.X'
    implementation 'com.android.support:design:X.X.X'

    // donde X.X.X es la versión que prefieras usar
}
  • En primer lugar debemos generar un nuevo Layout para nuestro BottomNavigationView, este View debe tener asociado un menu:
<android.support.design.widget.BottomNavigationView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/bottombar"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_gravity="bottom|end"

    android:background="@color/colorPrimary"
    app:itemBackground="@drawable/bottombar_itembackground"
    app:itemIconTint="@color/textColorWhite"
    app:itemTextColor="@color/textColorWhite"

    app:menu="@menu/bottombar_menu"
    />
  • El menú contendrá los botones del BottomNavigationView, cada item deberá tener un id, title e icon.
<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:id="@+id/search"
        android:title="@string/tab_search"
        android:icon="@drawable/ic_search"
        />
    <item
        android:id="@+id/home"
        android:title="@string/tab_home"
        android:icon="@drawable/ic_home"
        />
    <item
        android:id="@+id/profile"
        android:icon="@drawable/ic_user"
        android:title="@string/tab_profile" />
</menu>
  • Si regresas al primer punto, verás app:itemBackground="@drawable/bottombar_itembackground", es decir, que al fondo de cada botón le estamos asignado no sólo un color. Este recurso bottombar_itembackground contiene lo siguiente en este caso:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@color/colorPrimaryDark"/>
    <item android:state_pressed="true" android:drawable="@color/colorPrimaryDark"/>
    <item android:drawable="@color/colorPrimary" />
</selector>
  • Por defecto el botón tendrá el colorPrimary.

  • Cuando el botón sea presionado y cuando esté seleccionado, tendrá el colorPrimaryDark.

  • Listo, ya el ButtonNavigationView tiene el estilo que deseamos.

Escribe tu comentario
+ 2
1
6 años

Hi there are more exited games are add this website if you are like the more games to help this website play spades because this link are key of the more games when you are fell the board to play the more games.