Reputation: 7749
all. I'm working on setting up a home screen layout for an Android app in which there is a 4x4 grid of launch icons. My current structure for this is like this:
<TableLayout>
<TableRow>
<LinearLayout android:orientation="vertical">
<ImageButton>
<TextView>
</LinearLayout>
</TableRow>
...
...
...
</TableView>
When I run this, I get a force-close immediately. If I remove the LinearLayout from the equation, it works, but I don't get the alignment I want. Is there something inherently wrong with putting a linearlayout inside of a tablerow? Or is there probably something else going on here? As far as I can tell, my xml is all valid and I think I have all the required attributes I need. This is kind of driving me nuts, as there does not appear to be any documentation about this setup.
Upvotes: 1
Views: 1945
Reputation: 11887
I had the same problem a few times myself and usually it is a missing layout property such as android:layout_height
or something. As it has already been mentioned it is advisable to just go ahead and check your logcat to see what exactly is causing the problem. A structure of a LinearLayout
or RelativeLayout
within a TableLayout
(i.e. TableRow
) however generally works out fine - even though I do not have the experience to say if it is best practice to do so.
Upvotes: 1
Reputation: 31614
I get the same thing.
D/AndroidRuntime( 1378): Shutting down VM
W/dalvikvm( 1378): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
E/AndroidRuntime( 1378): FATAL EXCEPTION: main
E/AndroidRuntime( 1378): java.lang.RuntimeException: Unable to start activity ComponentInfo{...}: android.view.InflateException: Binary XML file line #19: Error inflating class LinearyLayout
Not a very descriptive trace, but I guess we simply are not allowed to make our layouts like this.
Upvotes: 0