Android:如何创建 3 个垂直点?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22440814/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Android: how to create 3 vertical dots?
提问by anthony
For example, in Google Play, each item in the lists had a 3 vertical dots in the right top corner to show a popup menu. What is the best way to create this 3 dots ?
例如,在 Google Play 中,列表中的每个项目在右上角都有一个 3 个垂直点来显示弹出菜单。创建这 3 个点的最佳方法是什么?
Thank you so much guys!
十分感谢大家!
回答by Shujito
This post is old, yes, but I've figured another way to include these dots without adding more graphics: use the vertical ellipsis, here's the string resource for whoever wants it:
这篇文章很旧,是的,但我想出了另一种方法来包含这些点而不添加更多图形:使用垂直省略号,这里是任何想要它的人的字符串资源:
<string name="vertical_ellipsis">⋮</string>
And then you can use it on a button as text.
然后你可以在按钮上使用它作为文本。
回答by android developer
for the 3-dots icon, you can find it either in the SDK, under ".../android-sdk\platforms\android-19\data\res..." , named "ic_menu_moreoverflow_normal_holo_light" or "ic_menu_moreoverflow_normal_holo_dark" , depending on the style of your app. note that it has multiple files on multiple folders, to allow correct selection of the images, according to the state of the button and the density of the device.
对于 3 点图标,您可以在 SDK 中的“ .../android-sdk\platforms\android-19\data\res...”下找到它,命名为“ ic_menu_moreoverflow_normal_holo_light”或“ ic_menu_moreoverflow_normal_holo_dark”,具体取决于在您的应用程序风格上。请注意,它在多个文件夹中有多个文件,以便根据按钮的状态和设备的密度正确选择图像。
Update: you can also find it here(search for "more") and here(inside "navigation", search for "more_vert") .
更新:您也可以在此处(搜索“more”)和此处(在“navigation”中,搜索“more_vert”)找到它。
I recommend the second one if you support VectorDrawable.
如果您支持 VectorDrawable,我推荐第二个。
Update: currently the newest file is abc_ic_menu_overflow_material.xmlVectorDrawable, which has this content:
更新:目前最新的文件是abc_ic_menu_overflow_material.xmlVectorDrawable,其中包含以下内容:
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0"
android:tint="?attr/colorControlNormal">
<path
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2c-1.1,0 -2,0.9 -2,2S10.9,8 12,8zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c1.1,0 2,-0.9 2,-2S13.1,10 12,10zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2c1.1,0 2,-0.9 2,-2S13.1,16 12,16z"
android:fillColor="@android:color/white"/>
</vector>
回答by CoolMind
Make you application support SVG. Then press File > New > Vector Asset
, select asset type "Clip Art", press button "Clip Art". In opened window search "more", select "more vert", press "OK", then "Next", "Finish".
使您的应用程序支持 SVG。然后按File > New > Vector Asset
,选择资产类型“剪贴画”,按“剪贴画”按钮。在打开的窗口搜索“更多”,选择“更多垂直”,按“确定”,然后“下一步”,“完成”。
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0"
>
<path
android:fillColor="#000000"
android:pathData="M12,8c1.1,0 2,-0.9 2,-2s-0.9,-2 -2,-2 -2,0.9 -2,2 0.9,2 2,2zM12,10c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2zM12,16c-1.1,0 -2,0.9 -2,2s0.9,2 2,2 2,-0.9 2,-2 -0.9,-2 -2,-2z"
/>
</vector>
回答by penduDev
You can download all material icons from https://github.com/google/material-design-icons. The three dot icon is called ic_more...
您可以从https://github.com/google/material-design-icons下载所有材质图标。三点图标称为ic_more...
I created this scriptto copy all versions(mdpi, ldpi, xdpi, xxdpi) to the android project. Might come in handy.
我创建了这个脚本来将所有版本(mdpi、ldpi、xdpi、xxdpi)复制到 android 项目。可能会派上用场。
回答by Amir Dora
create an xml drawable and add the following code, you can change color to white
创建一个xml drawable并添加以下代码,您可以将颜色更改为白色
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#000000"
android:pathData="M 256 192 C 291.346223989 192 320 220.653776011 320 256 C 320 291.346223989 291.346223989 320 256 320 C 220.653776011 320 192 291.346223989 192 256 C 192 220.653776011 220.653776011 192 256 192 Z" />
<path
android:fillColor="#000000"
android:pathData="M 256 384 C 291.346223989 384 320 412.653776011 320 448 C 320 483.346223989 291.346223989 512 256 512 C 220.653776011 512 192 483.346223989 192 448 C 192 412.653776011 220.653776011 384 256 384 Z" />
<path
android:fillColor="#000000"
android:pathData="M 256 0 C 291.346223989 0 320 28.6537760108 320 64 C 320 99.3462239892 291.346223989 128 256 128 C 220.653776011 128 192 99.3462239892 192 64 C 192 28.6537760108 220.653776011 0 256 0 Z" />
</vector>
回答by Shahid Sarwar
You are welcome :) android:background="@android:drawable/ic_menu_moreoverflow_normal_holo_light"
欢迎你:) android:background="@android:drawable/ic_menu_moreoverflow_normal_holo_light"