今天,在项目中,遇到一个问题:
由于需求原因,需要把achartengine画的chart放入ScrollView中,但是放入之后,就出了问题:
不是chart无法显示,就是chart的拖动以及缩放有问题。
解决方法:
1. 在achartengine的renderer加入一行代码:
renderer.setInScroll(true);
2. ScrollView的布局加入以下设置:
android:fillViewport="true"
由于需求原因,需要把achartengine画的chart放入ScrollView中,但是放入之后,就出了问题:
不是chart无法显示,就是chart的拖动以及缩放有问题。
解决方法:
1. 在achartengine的renderer加入一行代码:
renderer.setInScroll(true);
2. ScrollView的布局加入以下设置:
android:fillViewport="true"
另外,ScrollView的height要设成fill_parent
It must be set to ScrollView and has the following efect : when set to true, this attribute causes the scroll view’s child to expand to the height of the ScrollView if needed. When the child is taller than the ScrollView, the attribute
has no effect.
当你想让一个高度值不足scrollview的子控件fillparent的时候,单独的定义android:layout_height="fill_parent"是不起作用的,必须加上fillviewport属性,当子控件的高度值大于scrollview的高度时,这个标签就没有任何意义了。
本文介绍了解决AChartEngine生成的图表在嵌入ScrollView时出现的问题的方法,包括图表显示不全或拖动缩放异常的情况。通过调整renderer设置及ScrollView属性,实现图表完整显示并保持交互功能。
616

被折叠的 条评论
为什么被折叠?



