【问题标题】:How to make a horizontal bar chart using gradient color in android如何在android中使用渐变颜色制作水平条形图
【发布时间】:2015-03-06 09:30:20
【问题描述】:

我附上了截图。根据屏幕截图,我想让水平条形图与我的活动相同。我已经使用 MP Chart Library 完成了一半的内容。我无法添加从 3 到 9 的 x 轴值。也无法添加垂直网格。

请建议我该怎么做?

提前感谢您的帮助,我们将不胜感激。

【问题讨论】:

    标签: android graph bar-chart android-graphview


    【解决方案1】:

    使用 GraphView http://www.android-graphview.org/ 我希望它会有所帮助。

    【讨论】:

    【解决方案2】:

    在 /drawable 文件夹中为渐变创建一个 xml 文件,并将其应用到 LinearLayout 作为背景。角度必须为 0。

    <shape xmlns:android="http://schemas.android.com/apk/res/android">
        <gradient
            android:startColor="#000000"
            android:endColor="#ff3399"
            android:angle="0"/>
    </shape>
    
    
    <LinearLayout 
        android:id="@+id/bar_1" 
        android:layout_width="wrap_content" 
        android:background="@drawable/my_gradient"> 
    </LinearLayout>
    

    关于背景:试试GridLayout,它可以“聚合”单元格。但这可能很棘手。

    【讨论】:

    • 我会尝试这样做,但我主要关注的是我无法添加图像中显示的值的图表。
    • 如果您对开箱即用的解决方案感到满意 --> code.google.com/p/achartengine :)
    猜你喜欢
    • 2023-03-19
    • 2018-08-30
    • 1970-01-01
    • 2021-12-22
    • 2019-08-27
    • 2017-04-30
    • 2016-10-01
    • 1970-01-01
    • 2018-01-13
    相关资源
    最近更新 更多