2014-07-11 3 views
0

저는 GraphView 라이브러리로 작업했습니다. 프로그래밍 방식으로 GraphView를 추가해야합니다.스크롤 뷰의 RelativeLayout에 그래프 뷰 추가하기

그래프를 RelativeLayout에 추가 할 때 텍스트 뷰가 페이지를 채우면 그래프가 표시되지 않습니다. 그러나 텍스트 뷰가 비어 있거나 페이지를 완전히 채우지 않으면 그래프가 표시되지만 전부는 아닙니다. 전혀 스크롤하지 않습니다 ....

나는 그래프를 textview 아래에 추가하려고합니다.

이 일이에

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 LineGraphView(getActivity(), "GraphViewDemo"); 
      graphView.addSeries(exampleSeries); // data 
      RelativeLayout layout = (RelativeLayout) v.findViewById(R.id.reletive_layout); 
      RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
        LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); 
      params.addRule(RelativeLayout.BELOW, tv2.getId()); 
      layout.addView(graphView,params); 

난 주식, 사전에 감사합니다 ... 내 XML

<ScrollView 
     android:id="@+id/ScrollView02" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:fillViewport="true" 
     android:scrollbars="none" > 

     <RelativeLayout 
      android:id="@+id/reletive_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" > 
     <TextView 
       android:id="@+id/textView1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_alignParentTop="true"/> 
    </RelativeLayout> 
    </ScrollView> 

코드입니다.

답변

1

도움이되기를 바랍니다. 만약 내가 Graphview 후에 프로그래밍 방식으로 Textview를 추가하면 잘 동작합니다. 그건 그렇고 내가 textview에 대한 텍스트를 설정해야합니다.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/scroll1" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fillViewport="true" 
android:scrollbars="none" > 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="30dp" /> 

    <LinearLayout 
     android:id="@+id/layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
    </LinearLayout> 
</LinearLayout> 

코드 :

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

     final GraphView graphView = new LineGraphView(
      this // context 
      , "GraphViewDemo" // heading 
     ); 
     graphView.addSeries(exampleSeries); // data 

     LinearLayout layout = (LinearLayout) findViewById(R.id.layout); 
     layout.addView(graphView); 

     TextView tv3=new TextView(getApplicationContext()); 
     tv3.setText("    "); 
     layout.addView(tv3); 

이 (... 나는 그것이 일어날 이유를 알고 그나마 지금 작동) 당신의 도움에 대한

+0

이것은 실제로 작동합니다! 아직 알려지지 않은 이유 : D –

1

GraphView를 textview 아래에 원하는대로 android : orientation = "vertical"로 설정하십시오. 그리고 RelativeLayout 대신 LinearLayout을 사용하십시오.

RelativeLayout을 사용하려면 WRAP_CONTENT 및 TextView 및 GraphView의 중력이 각각 "위쪽"및 "아래쪽"인 경우 대신 RelativeLayout의 LayoutParams가 MATCH_PARENT 여야합니다.

은 내가 실수로 작동하는 방법을 발견

+0

덕분에, 내가있는 LinearLayout하지만 동일한 결과를 시도 , 그리고 relativelayout 같은 ... –