2014-01-23 5 views
1

나는 각 막대가 ViewTextView 중 하나로 구성된 android에서 막 대형 차트를 만들려고합니다. 이 셀을 HorizontalScrollView에 추가합니다. 이것은 잘 작동, 내 모든 막대가 나타납니다.요소를 곱하여 막대 차트의 요소 크기 조정

이제 요소를 곱하여 막대의 크기를 조정하고 싶습니다.

이것은 내가 사용하는 활동 클래스입니다.

private ViewGroup linearScrollLayout; 
private HorizontalScrollView hScrollView; 
private ArrayList<NutrientCell> nutrientsData; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.box_plot); 
    this.hScrollView = (HorizontalScrollView) findViewById(R.id.horizontalScrollView1); 
    this.linearScrollLayout = (ViewGroup) this.hScrollView 
      .findViewById(R.id.linearScrollLayout); 

    try { 
     Intent intent = getIntent(); 
     this.nutrientsData = (ArrayList<NutrientCell>) intent 
       .getSerializableExtra("nutrientsData"); 
     // 
    } catch (Exception e) { 
     // TODO: handle exception 
    } 
    this.initChart(); 
} 

private void initChart() { 

    for (NutrientCell c : this.nutrientsData) { 

     RelativeLayout rlt = (RelativeLayout) getLayoutInflater().inflate(
       R.layout.hv_boxplot_cell, this.linearScrollLayout, false); 

     ((TextView) rlt.findViewById(R.id.textView1)).setText(c 
       .getNutrientName().toString()); 

     View v = ((View) rlt.findViewById(R.id.vv1)); 
     v.setBackgroundColor(c.getColor()); 

     this.linearScrollLayout.addView(rlt); 
    } 

} 

이제 initChart() 검색된 루프 I가 percentage 변수를 갖는 각각의 ArrayList 모든 요소를 ​​반복. 이것은 높이를 곱하는 변수입니다. initChart에있는 부풀려진 RelativeLayout의 LayoutParams 높이를 곱하려고했지만 onCreate()에서 호출되었으므로 높이 속성이 올바르지 않습니다.

그래서 어떻게 내가보기에 추가 팽창 RelativeLayout의는 높이가 c (c.getPercentage())에서 얻은 비율

답변

0

정확히 비율이 사용되는지에 해당하는 것을 확인 할 수 있습니까? 백분율로 초기 크기를 기준으로보기의 크기를 조절하는 경우보기의 setScaleY() 메서드를 사용하여 높이를 변경할 수 있습니다.