2014-06-13 63 views
0

我在我的應用程序中使用Afreechart實現了一個簡單的圖表,沒有任何問題。 該圖表在模擬器中以及我的舊3.5英寸設備中全屏顯示正確,但如果將其安裝在新的5英寸智能手機中,則圖表佔據屏幕高度的僅一半。AFreeChart Android全屏視圖

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

解決。它取決於AfreeChart DemoView擴展類。

public class EconormaChart extends DemoView { 
    } 

評論DemoView類中該線和圖表適用於所有分辨率:

  

     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; 
        }