AFreeChart Android全屏视图

时间:2014-06-13 14:45:56

标签: android charts fullscreen jfreechart

我使用Afreechart在我的应用程序中实现了一个简单的图表,没有任何问题。 图表在模拟器中以及在旧的3,5英寸设备中全屏显示,但如果我将其安装在新的5英寸智能手机中,则图表仅占屏幕高度的一半。

public class ChartActivity extends Activity {

    private LinearLayout linearlayout;

    /**
     * Called when the activity is starting.
     * @param savedInstanceState
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Intent myIntent = getIntent(); 
        String sonda = myIntent.getStringExtra("sonda");

        EconormaChart chartView = new EconormaChart(this, sonda);
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        linearlayout = (LinearLayout) View.inflate(this, R.layout.chart, null);
        linearlayout.addView(chartView);
        setContentView(linearlayout);
    }
}

XML

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:orientation="vertical">
</LinearLayout>

1 个答案:

答案 0 :(得分:1)

解决。它取决于AfreeChart DemoView扩展类。

 public class EconormaChart extends DemoView {
  }

在DemoView类中注释这一行,而Chart适用于所有分辨率:

 

       if (drawWidth < this.minimumDrawWidth) {
          this.scaleX = drawWidth / this.minimumDrawWidth;         
          drawWidth = this.minimumDrawWidth;
       }
          else if (drawWidth > this.maximumDrawWid
          this.scaleX = drawWidth / this.maximumDrawWid
         drawWidth = this.maximumDrawWidth;
       }


        if (drawHeight < this.minimumDrawHeight) {
            this.scaleY = drawHeight / this.minimumDrawHeight;
            drawHeight = this.minimumDrawHeight;
        }
        else if (drawHeight > this.maximumDrawHeight) {
            this.scaleY = drawHeight / this.maximumDrawHeight;
            drawHeight = this.maximumDrawHeight;
        }