Android Java如何制作单条形图
我需要显示一个“图形”,其中框的一部分被着色。 在框中它会有文本,但我希望能够在背景上添加颜色以显示数字有多高。看我用excel做的图表。 (我想我不被允许上传图片。所以不知道如何解释这个..
点击此处查看Excel图片
有人知道怎么做吗?
I need to show a "graphic" with part of the box colored in.
In the box it it will have text, but then I want to be able to put a color on the background to show how high the numbers are. see the graphic I made in excel. (I guess I am not allowed to upload a picture. So not sure how to explain this..
Click here to see the excel picture
Anyone know how to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以简单地创建一个 XML Drawable,如下所示(保存在 res/drawable 下):
然后只需使用 TextView,将此 Drawable 设置为您的
android:background
属性。You can simply make an XML Drawable, something like this (save under res/drawable):
then just use a TextView, with this Drawable set as your
android:background
attribute.您希望颜色为每个值动态改变颜色吗?或者您是否同意只使用几种颜色“级别”(例如红色、黄色、绿色)。
更简单的方法是只设置一些颜色并在 Photoshop 中创建这些渐变,然后使用背景属性将这些纹理应用到 ImageView 的背面。
以下是有关视图如何工作的一些教程: http://developer.android.com/资源/tutorials/views/index.html
Do you want the colour to dynamically change colour for each value? Or are you okay with just having a few colour "levels" (e.g. red, yellow, green).
The easier route would be to just have a few set colours and create those gradients in photoshop and then apply those textures to the back of an ImageView using the background attribute.
Here are some tutorials on how views work: http://developer.android.com/resources/tutorials/views/index.html