关于canvas画统计图与统计图的水平或坚直滑动
来源:互联网 发布:网络宣传部是干什么的 编辑:程序博客网 时间:2024/04/26 22:02
前段时间出于项目需求公司需要用到制作折线图或者柱状图由于一般的统计图都是很宽的,手机屏幕又太窄,所以需要折线图能够水平滑动,当时想到了HorizontalScrollview 但是当使用horizontalscrollview.addview();这个方法时被告知添加的view里面不能出现ondraw或者draw方法,当时为了解决问题,临时出了view类里面的ontouch事件监听手指的移动来改变view的scrollX或scrollY的方法来实现图表的水平移动。但是今天的客户提出了一个要求需要同一个activity里面出现三张表可以上下滑动,经过翻阅api以及尝试终于解决问题,帖出来作为自己的第一个blog;
package com.example.horizontal_relative;import com.example.chart.Chart1;import com.example.chart.Chart2;import com.example.chart.Chart3;import android.app.Activity;import android.os.Bundle;import android.view.LayoutInflater;import android.view.View;import android.view.Window;import android.widget.RelativeLayout;public class ScrollViewAcitvity extends Activity {private RelativeLayout layout;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.scroll_main);layout = (RelativeLayout) findViewById(R.id.layout);View scrollView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.scroll_view, null);RelativeLayout layout1 = (RelativeLayout) scrollView.findViewById(R.id.container1);View horizontalView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.horizontal_scroll_view, null);RelativeLayout layout_h = (RelativeLayout)horizontalView.findViewById(R.id.container);Chart1 chart1 = new Chart1(getApplicationContext());layout_h.addView(chart1);layout1.addView(horizontalView);RelativeLayout layout2 = (RelativeLayout) scrollView.findViewById(R.id.container2);Chart2 chart2 = new Chart2(getApplicationContext());layout2.addView(chart2);RelativeLayout layout3 = (RelativeLayout) scrollView.findViewById(R.id.container3);Chart3 chart3 = new Chart3(getApplicationContext());layout3.addView(chart3);layout.removeAllViews();layout.addView(scrollView);}}
<?xml version="1.0" encoding="utf-8"?><ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RelativeLayout android:id="@+id/container1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="2.0dip" /> <RelativeLayout android:id="@+id/container2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="2.0dip" /> <RelativeLayout android:id="@+id/container3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:padding="2.0dip" /> </LinearLayout></ScrollView><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/main_background" > <RelativeLayout android:id="@+id/layout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentRight="true" android:layout_alignParentTop="true" > </RelativeLayout></RelativeLayout>
0 0
- 关于canvas画统计图与统计图的水平或坚直滑动
- 统计图
- 统计图
- 利用canvas画rect画出条形统计图
- 关于flash+xml生成的统计图
- canvas制作圆形百分比统计图
- 绘制canvas圆形统计图插件
- 学习Canvas 画圆锥,并且作为一个统计图
- Android:使用canvas绘柱状统计图(自动计算宽高及分度值、可左右滑动)
- android画统计图的chart engine
- 超漂亮的统计图
- 统计图超链接的使用
- 统计图的绘制
- 润乾-统计图的使用方法
- Matlab--统计图的绘制
- Matplotlib简介和pyplot的简单使用——直方统计图和轮廓曲线
- fushionChars画动态统计图
- Python画柱状统计图
- JConsole命令(Java Monitoring and Management Console)
- jmap命令(Java Memory Map)
- 框架中新增级联查询
- Java VisualVM(Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool)
- ubuntu vsftpd安装
- 关于canvas画统计图与统计图的水平或坚直滑动
- HashSet、HashMap、ArrayList、LinkedList、Vector
- java学习笔记07
- 数据库--数据库链接池--DBCP--Spring 连接池之 DBCP
- 新手入门--输出格式八
- SMAQ:海量数据的存储计算和查询模型(译)
- (一)Makefile研究 —— 必备语法
- 调用ejb出现java.lang.ClassCastException异常
- 静态检查-----pclint使用