Android 底部导航栏自定义
Android bottom navigation bar customization
我已经成功实现了简单的底部栏,它看起来像图 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"
如有任何查询follow this link
我已经成功实现了简单的底部栏,它看起来像图 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"
如有任何查询follow this link