2014-12-03 4 views
1
package com.example.graph;          

public class MainActivity extends Activity       
{ 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState);       
     setContentView(R.layout.activity_main);     

     GraphViewSeries exampleSeries = new GraphViewSeries(new GraphViewData[]{ 
       new GraphViewData(1, 2.0d) 
       , new GraphViewData(2, 1.5d) 
       , new GraphViewData(3, 2.5d) 
       , new GraphViewData(4, 1.0d) 
      }); 

     GraphView graphView = new BarGraphView(MainActivity.this,"GraphViewDemo"); 
     graphView.addSeries(exampleSeries); 
     graphView.setBackgroundColor(getResources().getColor(android.R.color.holo_green_light)); 
     graphView.setBackgroundColor(Color.argb(50, 50, 0, 200));   
    } 
    public boolean onCreateOptionsMenu(Menu menu) 
    { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.main, menu); 
     return true; 
    } 
} 
당신은 graphView.setBackground 속성을 설정하여 graphview의 배경 이미지를 사용할 수 있지만, 안드로이드는 최소 API 인 경우 불평
+0

graphview에 실제로 추가하려는 것은 무엇입니까? – vembutech

+0

난 그냥 그래프보기 또는 그래프 시트 뒤에 이미지를 원한다. – nirmalnk

답변

0

미만 16

int imageResource = getResources().getIdentifier("@drawable/output_background", null, getPackageName()); 
Drawable graph_background = getResources().getDrawable(imageResource); 
graphView.setBackground(graph_background); 
0

또 다른 옵션은 그래프를 ImageView 위에 쌓는 것입니다. 따라서 GraphView를 FrameLayout에 추가하는 경우 해당 FrameLayout에 이미 이미지를 표시하는 ImageView가 포함되어 있어야합니다.