Reputation: 68
I'm working on an App, which contains a Table Layout in a Scrollview. I want the Table to fill the width of the screen, but I don't really now what to do.
I tried to first set the scrollView to fill_parent, but then I get dozens of "unhandled event loop exceptions". And about three "Invalid preference page path: XML Syntax" Errors.
If I just try to set the table layout to fill_parent just nothing happens. Here is an excerpt of my "scroll-table construction"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btnNew"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="New" />
<Button
android:id="@+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.20"
android:text="Delete" />
</LinearLayout>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.20" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:id="@+id/tableRow1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/cell_shape2"
android:padding="5dp"
android:textAppearance="?android:attr/textAppearanceSmall" />
... etc. (much stuff not necessary).
I hope you can give me a hint, because I really don't know why my scrollview can't fit the parent width and I don't know, if it would help, if it would fit.
Upvotes: 1
Views: 3333
Reputation: 958
If you're using Eclipse, try to use menu Project -> Clean... -> (select your project) -> Press OK. This is sometimes needed to recompile the xml resources when you've changed something.
Also, I don't think you can have a both a LinearLayout and a ScrollView in the root of an XML-layout.
If you'd like the columns content to fill you probably need to set
android:stretchColumns="1"
on the TableLayout, and
android:layout_column="1"
on the TextView.
You could also try and use
android:fillViewport="true"
on the ScrollView.
Upvotes: 7