Android 水平柱状图

最近由于公司的需求需要实现一款水平的柱状图用于进行统计价格的,于是就研究了一下,上网也搜了一些demo,但是感觉不是很好,于是自己就通过一些例子并结合自己所掌握的一些知识就写了一个demo供大家参考,如果有什么不足的地方还请大家多多指教。
我要实现的柱状图是一个水平的而且是可以带有动画的,先看看效果图吧
这里写图片描述
多余的话就不说了,上代码

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button btn_hv1 = (Button) findViewById(R.id.btn_hv1);
        new WeightUtil(getApplicationContext()).mLayoutParams_Btn(btn_hv1);

        HistogramView hv1 = (HistogramView) findViewById(R.id.hv1);
        hv1.setProgress(0.2);
        new WeightUtil(getApplicationContext()).mLayoutParams_View(hv1);
        hv1.setRateBackgroundColor("#FF8B6F");
        hv1.setOrientation(LinearLayout.HORIZONTAL);

        Button btn_hv2 = (Button) findViewById(R.id.btn_hv2);
        new WeightUtil(getApplicationContext()).mLayoutParams_Btn(btn_hv2);
        double d = 293;
        double b = 700;
        double p2 = d / b;

        TextView tv_hv2 = (TextView) findViewById(R.id.tv_hv2);
        tv_hv2.setText("¥ 293.00");
        new WeightUtil(getApplicationContext()).mLayoutParams_Text(tv_hv2, p2);

        HistogramView hv2 = (HistogramView) findViewById(R.id.hv2);
        hv2.setProgress(p2);
        new WeightUtil(getApplicationContext()).mLayoutParams_View(hv2);
        hv2.setRateBackgroundColor("#F8D478");
        hv2.setOrientation(LinearLayout.HORIZONTAL);




        Button btn_hv3 = (Button) findViewById(R.id.btn_hv3);
        new WeightUtil(getApplicationContext()).mLayoutParams_Btn(btn_hv3);

        HistogramView hv3 = (HistogramView) findViewById(R.id.hv3);
        hv3.setProgress(0.6);
        new WeightUtil(getApplicationContext()).mLayoutParams_View(hv3);
        hv3.setRateBackgroundColor("#72CFF6");
        hv3.setOrientation(LinearLayout.HORIZONTAL);


        double d4 = 553;
        double b4 = 700;
        double p4 = d4/b4;
        Button btn_hv4 = (Button) findViewById(R.id.btn_hv4);
        new WeightUtil(getApplicationContext())
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值