I’m totally lost here. It should be dead simple but I can’t center a Dial chart from AChartEngine in my layout.
I am following the Demo example to the letter but it still does not work for me and I’m out of ideas!
My last layout test follows:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="@+id/txt"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center"
android:text="TEST-TEST" />
<LinearLayout
android:id="@+id/graph1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center" />
</LinearLayout>
I get a perfectly centered “TEST-TEST” text and the dial to the right of that but around 55% of the screen size, clearly to the left of where it should be centered. It’s actually not getting clipped to the second layout because of the margins (I am using the demo ones too).
If I change the graph for another textview I get it perfectly centered as expected.
Ideas anyone?
Try adding this call:
This will help in cases when the chart view is added to a custom layout.