我正在尝试在我的 Android 应用程序底部导航栏的顶部绘制边距。这就是我现在拥有的:
我想要实现的是底部栏上的黑色顶部边框。我使用拆分操作栏创建了它。这是我的 xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@android:style/Theme.Holo.Light">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarSplitStyle">@style/MyBottomBar</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@android:style/Widget.Holo.Light.ActionBar.Solid.Inverse">
<item name="@android:background">@color/white</item>
<item name="@android:textColor">@color/black</item>
</style>
<!--bottom bar style-->
<style name="MyBottomBar">
<item name="android:backgroundSplit">@color/white</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTextStyle"
parent="@android:style/TextAppearance.Holo.Widget.ActionBar.Title">
<item name="@android:textColor">@color/black</item>
</style>
</resources>
我不知道我需要给底栏什么,Android 的文档也不是那么清楚。请帮帮我!谢谢大家!
最佳答案
您需要在 drawable 文件夹中创建一个新的 .xml 文件。您可以将其称为“bottom_navbar_background.xml”。像这样在文件上画一个矩形:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="1dp">
<shape
android:dither="true"
android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="@color/black" />
</shape>
</item>
<item android:top="1dp">
<shape
android:dither="true"
android:shape="rectangle">
<solid android:color="@android:color/white" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
</shape>
</item>
</layer-list>
像这样把它作为 splitNavbar 自定义主题的背景:
<item name="android:backgroundSplit">@drawable/bottom_navbar_background</item>
等等:你的导航栏上有顶部边框!
关于android - 如何在底部导航栏上绘制顶部边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22899316/