< TableLayout>< TableRow>< LinearLayout>讨厌我.强制关闭运行.安卓 [英] <TableLayout><TableRow><LinearLayout> hates me. Force close on run. Android
问题描述
全部.我正在为Android应用程序设置主屏幕布局,其中有一个4x4的启动图标网格.我目前的结构如下:
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>
运行此命令时,我会立即强制关闭.如果我从等式中删除LinearLayout,它可以工作,但是我没有得到想要的对齐方式.将线性布局放置在工作台内部是否存在本质上的问题?还是这里可能还有其他事情?据我所知,我的xml都是有效的,并且我认为自己具有所需的所有必需属性.这有点使我发疯,因为似乎没有关于此设置的任何文档.
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.
推荐答案
我几次也遇到相同的问题,通常这是缺少的布局属性,例如android:layout_height
之类的东西.正如已经提到的那样,建议您继续检查日志,以查看到底是什么引起了该问题. TableLayout
(即TableRow
)中的LinearLayout
或RelativeLayout
的结构通常可以很好地工作-即使我没有经验说这样做是否是最佳实践.
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.
这篇关于< TableLayout>< TableRow>< LinearLayout>讨厌我.强制关闭运行.安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!