Android底部导航栏自定义 [英] Android bottom navigation bar customization

查看:1154
本文介绍了Android底部导航栏自定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功实现了简单的底部栏,它看起来像图1.但是我想进一步对其进行自定义,使其看起来像Youtube android应用程序中的底部栏,当您单击其中一项时,它会散布开来.阴影效果.

我当前的底部栏:

Youtube的底部栏

我还想自定义它,使其看起来像官方网站上的一样,并带有单击某些项目时的动画.

任何摘录或教程链接将不胜感激.谢谢

解决方案

尝试一下

使用Android波纹效果自定义颜色:

在可绘制文件夹中创建button.xml

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/colorPrimaryDark"/>
<item android:drawable="@color/colorPrimary"/>
</selector>

在drawable-v21文件夹中创建button.xml

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
<item android:drawable="@color/colorPrimary" /> 
</ripple>

应用于主题

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlHighlight">@color/colorPrimaryDark</item>
</style>

现在您可以将button.xml设置为视图的背景.

 android:background="@drawable/button"

如果有任何查询遵循此链接

I have successfully implementing simple bottom bar and it looks like picture 1. But I wanted to customize it further so it can looks like the bottom bar in Youtube's android apps, which when you clicked in one of the item, it will spread shadowing effect.

My current bottom bar:

Youtube's bottom bar

I would also like to customize it to look like the one in the official site with some animation when items are clicked.

Any snippet or tutorial links would be appreciated. Thanks

解决方案

try this

Custom color using Android Ripple Effect:

Create button.xml in drawable folder

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true" android:drawable="@color/colorPrimaryDark"/>
<item android:drawable="@color/colorPrimary"/>
</selector>

Create button.xml in drawable-v21 folder

<ripple xmlns:android="http://schemas.android.com/apk/res/android"
    android:color="?android:colorControlHighlight">
<item android:drawable="@color/colorPrimary" /> 
</ripple>

apply in your theme

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
    <item name="colorControlHighlight">@color/colorPrimaryDark</item>
</style>

now you can set button.xml as background of your view.

 android:background="@drawable/button"

in case of any query follow this link

这篇关于Android底部导航栏自定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆