Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Pie AChartEngine不在ScrollView Android中滚动?_Android_Scrollview_Achartengine_Pie Chart - Fatal编程技术网

Pie AChartEngine不在ScrollView Android中滚动?

Pie AChartEngine不在ScrollView Android中滚动?,android,scrollview,achartengine,pie-chart,Android,Scrollview,Achartengine,Pie Chart,我正在学习android中的Pie AChartEngine,我想尝试在ScrollView中添加一些Pie。但是这个没有滚动。。。如何解决 这是我的xml <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" androi

我正在学习android中的Pie AChartEngine,我想尝试在ScrollView中添加一些Pie。但是这个没有滚动。。。如何解决

这是我的xml

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
android:layout_height="fill_parent"
        android:fillViewport="true" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:id="@+id/general" >

            <TextView
                android:id="@+id/tv_title"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="@string/str_tv_title" />

            <LinearLayout
                android:id="@+id/chart_container"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
            </LinearLayout>

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Large Text"
                android:textAppearance="?android:attr/textAppearanceLarge" />

            <TextView
                android:id="@+id/textView2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Medium Text"
                android:textAppearance="?android:attr/textAppearanceMedium" />

            <TextView
                android:id="@+id/textView3"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView" />




        </LinearLayout>
    </ScrollView>

这个爪哇

 private void openChart(){      

    // Pie Chart Slice Names
    code = new String[] {
            "Eclair & Older", "Froyo", "Gingerbread", "Honeycomb",
            "IceCream Sandwich", "Jelly Bean" 
    };      

    // Pie Chart Slice Values
    double[] distribution = { 3.9, 12.9, 55.8, 1.9, 23.7, 1.8 } ;

    // Color of each Pie Chart Slices
    int[] colors = { Color.BLUE, Color.MAGENTA, Color.GREEN, Color.CYAN, Color.RED,
                     Color.YELLOW };

    DisplayMetrics metrics = getBaseContext().getResources().getDisplayMetrics();
    float val = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, 18, metrics);

    // Instantiating CategorySeries to plot Pie Chart       
    CategorySeries distributionSeries = new CategorySeries(" Android version distribution as on October 1, 2012");
    for(int i=0 ;i < distribution.length;i++){
        // Adding a slice with its values and name to the Pie Chart
        distributionSeries.add(code[i], distribution[i]);
    }   

    // Instantiating a renderer for the Pie Chart
    DefaultRenderer defaultRenderer  = new DefaultRenderer();       
    for(int i = 0 ;i<distribution.length;i++){ 

        // Instantiating a render for the slice
        SimpleSeriesRenderer seriesRenderer = new SimpleSeriesRenderer();       
        seriesRenderer.setColor(colors[i]);
        seriesRenderer.setDisplayChartValues(true);

        // Adding the renderer of a slice to the renderer of the pie chart
        defaultRenderer.addSeriesRenderer(seriesRenderer);
    }

    defaultRenderer.setChartTitle("Android version distribution as on October 1, 2012 ");
    defaultRenderer.setChartTitleTextSize(20);
    defaultRenderer.setZoomButtonsVisible(true); 
    defaultRenderer.setLabelsTextSize(val);

    // Getting a reference to view group linear layout chart_container
    LinearLayout chartContainer = (LinearLayout) findViewById(R.id.chart_container);


    // Getting PieChartView to add to the custom layout
    mChart = ChartFactory.getPieChartView(getBaseContext(), distributionSeries, defaultRenderer);

    defaultRenderer.setClickEnabled(true);
    defaultRenderer.setZoomEnabled(true);
    defaultRenderer.setSelectableBuffer(10);
    defaultRenderer.setApplyBackgroundColor(true);
    defaultRenderer.setBackgroundColor(Color.argb(100, 50, 50, 50));
    defaultRenderer.setChartTitleTextSize(20);
    defaultRenderer.setLabelsTextSize(20);
    defaultRenderer.setLegendTextSize(20);
    defaultRenderer.setZoomButtonsVisible(false);
    defaultRenderer.setInScroll(true);
    defaultRenderer.setStartAngle(90);
    defaultRenderer.setPanEnabled(true);

    mChart.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            SeriesSelection seriesSelection = mChart.getCurrentSeriesAndPoint();
            if (seriesSelection != null) {

                // Getting the name of the clicked slice
                int seriesIndex = seriesSelection.getPointIndex();
                String selectedSeries="";
                selectedSeries = code[seriesIndex];                 

                // Getting the value of the clicked slice
                double value = seriesSelection.getXValue();
                DecimalFormat dFormat = new DecimalFormat("#.#");

                // Displaying the message
                Toast.makeText(
                        getBaseContext(),
                        selectedSeries + " : "  + Double.valueOf(dFormat.format(value)) + " % " ,
                        Toast.LENGTH_SHORT).show();
            }
    }
    });

    // Adding the pie chart to the custom layout
    chartContainer.addView(mChart);
}
private void openChart(){
//饼图切片名称
代码=新字符串[]{
“Eclair&Older”、“Froyo”、“姜饼”、“蜂巢”,
“冰淇淋三明治”、“果冻豆”
};      
//饼图切片值
双[]分布={3.9,12.9,55.8,1.9,23.7,1.8};
//每个饼图切片的颜色
int[]colors={Color.BLUE,Color.洋红,Color.GREEN,Color.CYAN,Color.RED,
颜色:黄色};
DisplayMetrics metrics=getBaseContext().getResources().getDisplayMetrics();
float val=TypedValue.applyDimension(TypedValue.COMPLEX\u UNIT\u SP,18,度量);
//实例化类别以绘制饼图
CategorySeries distributionSeries=新的CategorySeries(“截至2012年10月1日的Android版本发行”);
for(int i=0;i
尝试在此处将android:layout\u height设置为
wrap\u content
mrender.setZoomEnabled(false)

mrender.setPanEnabled(false)

mrender.setZoomRate(6.0f)

mrender.setShowLabels(真)

mRenderer.setFitLegend(真)

setInScroll先生(真)


这对我来说很有效。

像这里?``我做了更改,但仍然不起作用:(,,可能是您有defaultRenderer.setPanEnabled(true);set?听起来好像有什么东西在ScrollView之前截获了这个手势。是的,在我的代码中我设置了defaultRenderer.setPanEnabled(true);我尝试删除或设置了defaultRenderer.setPanEnabled(false),仍然不工作。。。
 <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:id="@+id/general" >