TableLayout / Custom View problem

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

TableLayout / Custom View problem

Postby baal00 » Fri Jun 12, 2009 9:17 pm

Hi,

I'm developing the UI for an home-automation/sustainability application and wanted to display some data in a graph so I used the custom-view graph class by Arno den Hond. I put the graph in a TableLayout together with some buttons and labels. Unfortunately I encountered a strange problem: as soon as I add the graph into the XML layout file all the widgets which are supposed to be displayed beneath the graph will be ignored.

XML file:

<TableLayout
android:id="@+id/tempTable"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">

<TableRow
android:id="@+id/dateRow">

<TextView
android:id="@+id/dateView"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="" />

</TableRow>

<TableRow
android:id="@+id/buttonRow">

<ToggleButton
android:id="@+id/monthButton"
android:layout_width="70px"
android:layout_height="wrap_content"

android:textOff="Month"
android:textOn="Month"/>

<ToggleButton
android:id="@+id/weekButton"
android:layout_width="70px"
android:layout_height="wrap_content"
android:textOff="Week"
android:textOn="Week"/>

<ToggleButton
android:id="@+id/dayButton"
android:layout_width="70px"
android:layout_height="wrap_content"
android:textOff="Day"
android:textOn="Day"/>
</TableRow>

<android.MobileSafer.GraphView
android:id="@+id/graph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<TableRow>

<TextView
android:id="@+id/compare"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Compare To:" />

<Spinner
android:id="@+id/compareSpinner"
android:layout_width="150px"
android:layout_height="30px"
android:drawSelectorOnTop="true"
android:prompt="@string/compare_promt"/>

</TableRow>
</TableLayout>

basically the whole table row beneath the graph will not be displayed. I also put the graph before the three buttons to see what happens and all the widgets beneath the graph will be ignored again and the graph will be stretched to fill the rest of the screen. Only if I change the visibility of the graph (via android:visibility) to "gone" the other widgets will be displayed.

I would hate to put all the buttons over the graph and actually it would be interesting to know what causes this, so I hope somebody could shed some light on the problem.

Thx,
Christian
baal00
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 08, 2009 6:10 pm
Location: Pittsburgh

Top

Postby nmc » Sat Jun 13, 2009 1:52 pm

Did you try putting the graph-view inside a tablerow-tag?
I dont think these tags are there for fun :wink:
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby baal00 » Sat Jun 13, 2009 2:19 pm

Actually I did. :-) Unfortunately it didn't do anything besides messing up the layout (button size changed etc.).

Hmmm btw. is there a good tutorial available which describes how to handle the TableLayout? Especially in regard to column span.
baal00
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 08, 2009 6:10 pm
Location: Pittsburgh

Postby nmc » Sun Jun 14, 2009 10:31 am

Then I would think the graph-view handles the measuresize thing in a way that it is always using the entire space left on the screen :-/
In this case you could either try using layout_height or place the graph-view at the bottom of your screen.

column span: simply place something like 'android:layout_span="2"' in your views.
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Postby baal00 » Sun Jun 14, 2009 12:54 pm

Hmmm ok was also my guess at the end, but thx anyways.

I tried using column span but it didn't provide the result I hoped for, but I'll see if I can make it work.
baal00
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 08, 2009 6:10 pm
Location: Pittsburgh

Postby nmc » Sun Jun 14, 2009 11:28 pm

I tried using column span but it didn't provide the result I hoped for, but I'll see if I can make it work.

If you tell us about the problem, maybe somebody is able to help :)

Besides the table-becomes-wider-than-the-screen problem, tables seem to be good way to get a clean layout for complex data-views and input-forms.
nmc
Senior Developer
Senior Developer
 
Posts: 154
Joined: Thu Nov 27, 2008 8:30 pm
Location: Germany

Top

Postby baal00 » Sun Jun 14, 2009 11:48 pm

I agree tables are definitely a good way to get a clear layout. What bugs me a bit is that the cell width in each row is influenced by the other rows in the table. So e.g. I want to have three evenly sized buttons in my second row even if I have only two cells in the third row. There's probably a way to do this but I didn't find it yet.
baal00
Freshman
Freshman
 
Posts: 5
Joined: Mon Jun 08, 2009 6:10 pm
Location: Pittsburgh

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests