【发布时间】:2015-06-10 00:46:36
【问题描述】:
我已经实现了一个LinearGraph 并添加了LinearLayout(在xml 中,即LinearLayout 和id="linearLayout1")。
现在我想在这个图表之后添加表格,我需要使用ScrollView,因为表格将超过一行。
这是我尝试过但没有成功的 xml 之一...
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:orientation="vertical" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
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="vertical"
android:layout_above="@+id/tableLayout">
</LinearLayout>
<TableLayout
android:id="@+id/tableLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/my_drawable"
android:padding="5dp"
android:layout_alignParentBottom="true"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/home"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/my_drawable"
android:gravity="center"
android:padding="15dip"
android:text="Months" />
<TextView
android:id="@+id/status"
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/my_drawable"
android:gravity="center"
android:padding="15dip"
android:text="Number of Visits" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/my_drawable"
android:gravity="center"
android:padding="15dip"
android:text="January" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/my_drawable"
android:gravity="center"
android:padding="15dip"
android:text="1" />
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/my_drawable"
android:gravity="center"
android:padding="15dip"
android:text="Februrary" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:background="@drawable/my_drawable"
android:gravity="center"
android:padding="15dip"
android:text="" />
</TableRow>
</TableLayout>
</RelativeLayout>
</ScrollView>
【问题讨论】:
标签: java android android-layout scrollview android-relativelayout