如何在ActionBar的菜单项之间添加分隔线?

7
如何像Gmail应用程序一样在ActionBar中添加菜单项之间的分隔符? enter image description here
1个回答

2

为了制作自己的工具栏,我使用了一个黑色FrameLayout,在其中显示所有工具栏项目。我在每个项目上设置了layout_margin属性为1dp,这样它就会呈现出两侧有黑色分隔符的效果 - 如果您需要更大的间距,可以增加边距。

<FrameLayout 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="#000000">
    <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">
        <ImageButton ....... />
        <ImageButton ...... android:layout_marginLeft="1dp"/> <!-- this will be shown as a separator-->
    </LinearLayout>
</FrameLayout>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接