theJuls
theJuls

Reputation: 7460

AChartEngine graph doesn't show on small Android phone

I don't know if there is actually a solution for this, but I guess it doesn't hurt to try...

Basically, my application has a screen in which I show a graph. This works perfectly on a tablet, as shown here:

enter image description here

Unfortunately it turns in to a big hot mess if I try to show it on my small Galaxy Y phone: enter image description here

Here is the xml code for the small screened phone:

<LinearLayout
    android:id="@+id/chart_container"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@id/tv_title"
    android:orientation="horizontal"
    android:layout_above="@+id/checkbox_container">
</LinearLayout>

<LinearLayout
    android:id="@+id/checkbox_container"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="103dp"
        android:orientation="horizontal" >

        <CheckBox
            android:id="@+id/checkBox1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/distance_check_box" />

        <CheckBox
            android:id="@+id/checkBox2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="28dp"
            android:text="@string/time_check_box" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="271dp"
        android:layout_height="34dp"
        android:layout_marginTop="34dp"
        android:orientation="horizontal" >

        <CheckBox
            android:id="@+id/checkBox3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/velocity_check_box" />
        
        <CheckBox
            android:id="@+id/checkBox4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="28dp"
            android:text="@string/calories_check_box" />
    </LinearLayout>
</LinearLayout>

Can anything be done to allow the graph to also show on small phones like this?

Thanks!

Upvotes: 0

Views: 195

Answers (1)

keshav
keshav

Reputation: 3255

Hope it will work for you .

One thing you should keep chart_container height wrap_content for better result on all devices.

And if u r going to add more ui element you can use scrollview .

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:padding="10dp"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/chart_container"
        android:layout_width="match_parent"
        android:layout_height="250dp"
        android:background="#1231"
        android:orientation="horizontal" >
    </LinearLayout>

    <LinearLayout
        android:id="@+id/checkbox_container"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:id="@+id/linearLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <CheckBox
                android:id="@+id/checkBox1"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="distance" />

            <CheckBox
                android:id="@+id/checkBox2"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="time" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/linearLayout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <CheckBox
                android:id="@+id/checkBox3"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="velocity" />

            <CheckBox
                android:id="@+id/checkBox4"
                android:layout_width="0dp"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:text="calories" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>

Upvotes: 2

Related Questions