在LineChart之后添加TextView

时间:2015-06-09 19:38:51

标签: java android xml android-layout

Okey们,我有用achartengine制作的LineChart,这是截图:

https://www.dropbox.com/s/yk5nipe3b6upcaa/11414548_10205801109521047_408896835_n.jpg?dl=0

第一个XML

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:id="@+id/linearLayout1"
        android:orientation="horizontal">

    </LinearLayout>
    <TextView
        android:layout_below="@+id/linearLayout1"
        android:id="@+id/description"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:text="Description:"
        android:textStyle="bold"
        />
    <TextView
        android:layout_below="@+id/description"
        android:id="@+id/descriptionText"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
</RelativeLayout>

2ndXML

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">


    <LinearLayout android:id="@+id/linearLayout1" android:orientation="horizontal"
        android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1"/>


    <LinearLayout android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">
        <TextView

            android:id="@+id/description"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="Description:"
            android:textStyle="bold"
            />
        <TextView

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

</LinearLayout>

以下是onCreate()方法的代码:

 description=(TextView)findViewById(R.id.descriptionText);
    description.setText("sadasdasdas");

    setRendererStyling();
    if (mChartView == null) {
        LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayout1);
        mChartView = ChartFactory.getLineChartView(this, mDataset,
                mRenderer);
        mRenderer.setSelectableBuffer(100);
        layout.addView(mChartView, new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    } else
        mChartView.repaint();

我的问题是我想在图表之后放两个TextView。我尝试使用这两个不同的xml而没有结果。

我只得到说明:关于我的活动......

为Dharm编辑

    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:id="@+id/linearLayout1"
        android:orientation="horizontal"
        android:layout_above="@+id/scrollView">

    </LinearLayout>

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true" >
        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
                    <TextView
                        android:id="@+id/description"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="Description:"
                        android:textStyle="bold"
                        />
                    <TextView
                        android:layout_below="@+id/description"
                        android:id="@+id/descriptionText"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_alignParentBottom="true" />
        </LinearLayout>
    </ScrollView>
</RelativeLayout>

1 个答案:

答案 0 :(得分:0)

使用RelativeLayout并排列图形,使其底部与TextView的顶部对齐。您的第一个xml已关闭,但它正在创建一个填充屏幕的LinearLayout,然后将TextView放在其下方。

GNU C