Xperia(2.1)で検証していて、別のXperia(1.6)で動かしたところこんなエラーが発生。
E/AndroidRuntime(10100): Uncaught handler: thread main exiting due to uncaught exception<br /> E/AndroidRuntime(10100): java.lang.RuntimeException: mBaselineAlignedChildIndex of LinearLayout set to an index that is out of bounds.<br /> E/AndroidRuntime(10100): at android.widget.LinearLayout.getBaseline(LinearLayout.java:151)<br /> E/AndroidRuntime(10100): at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:644)<br /> E/AndroidRuntime(10100): at android.widget.LinearLayout.onMeasure(LinearLayout.java:280)<br /> E/AndroidRuntime(10100): at android.view.View.measure(View.java:7755)<br /> E/AndroidRuntime(10100): at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:892)<br /> E/AndroidRuntime(10100): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)<br /> E/AndroidRuntime(10100): at android.widget.ScrollView.onMeasure(ScrollView.java:276)<br /> E/AndroidRuntime(10100): at android.view.View.measure(View.java:7755)<br /> E/AndroidRuntime(10100): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)<br /> E/AndroidRuntime(10100): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)<br /> E/AndroidRuntime(10100): at android.view.View.measure(View.java:7755)<br /> E/AndroidRuntime(10100): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)<br /> E/AndroidRuntime(10100): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)<br /> E/AndroidRuntime(10100): at android.view.View.measure(View.java:7755)<br /> E/AndroidRuntime(10100): at android.widget.LinearLayout.measureVertical(LinearLayout.java:464)<br /> E/AndroidRuntime(10100): at android.widget.LinearLayout.onMeasure(LinearLayout.java:278)<br /> E/AndroidRuntime(10100): at android.view.View.measure(View.java:7755)<br /> E/AndroidRuntime(10100): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:2989)<br /> E/AndroidRuntime(10100): at android.widget.FrameLayout.onMeasure(FrameLayout.java:245)<br /> E/AndroidRuntime(10100): at android.view.View.measure(View.java:7755)<br /> E/AndroidRuntime(10100): at android.view.ViewRoot.performTraversals(ViewRoot.java:748)<br /> E/AndroidRuntime(10100): at android.view.ViewRoot.handleMessage(ViewRoot.java:1614)<br /> E/AndroidRuntime(10100): at android.os.Handler.dispatchMessage(Handler.java:99)<br /> E/AndroidRuntime(10100): at android.os.Looper.loop(Looper.java:123)<br /> E/AndroidRuntime(10100): at android.app.ActivityThread.main(ActivityThread.java:4203)<br /> E/AndroidRuntime(10100): at java.lang.reflect.Method.invokeNative(Native Method)<br /> E/AndroidRuntime(10100): at java.lang.reflect.Method.invoke(Method.java:521)<br /> E/AndroidRuntime(10100): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:799)<br /> E/AndroidRuntime(10100): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)<br /> E/AndroidRuntime(10100): at dalvik.system.NativeStart.main(Native Method)<br />
どうも1.6の不具合らしく、LinearLayout, TableLayout あたりをaddView()なしで表示しようとするとこういうエラーになるようで…。
何も表示しないビュー(テキストなしのTextView)を該当のレイアウトにはめ込んだら問題なく動くようになりました。
参考:
Issue 3484 – Creating LinearLayout without child views programatically fails.(Android Issues)