Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 文本视图在线性布局中,使用长字符串崩溃_Android_Android Linearlayout - Fatal编程技术网

Android 文本视图在线性布局中,使用长字符串崩溃

Android 文本视图在线性布局中,使用长字符串崩溃,android,android-linearlayout,Android,Android Linearlayout,使用Android,以下是布局xml文件的一部分: <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" android:textColor="#191919"> <TextView android:id="@+id/someTextField"

使用Android,以下是布局xml文件的一部分:

<LinearLayout
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:orientation="vertical"
   android:textColor="#191919">

      <TextView android:id="@+id/someTextField"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:layout_weight="1" 
          android:textStyle="bold" />

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

</LinearLayout>
这似乎工作正常,但当
newValue
足够长,可以在版面中容纳1行以上的文本时,我会崩溃:

09-06 21:36:48.208: ERROR/AndroidRuntime(6561): Uncaught handler: thread main exiting due to uncaught exception
09-06 21:36:48.248: ERROR/AndroidRuntime(6561): java.lang.StackOverflowError
09-06 21:36:48.248: ERROR/AndroidRuntime(6561):     at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
09-06 21:36:48.248: ERROR/AndroidRuntime(6561):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
(many more lines like this)

这些信息是否足以看出我可能做错了什么?当
newValue
足够短,只需一行时,它就可以正常工作。我曾考虑尝试使用
表格布局
,但似乎这正是
线性布局
的好处所在

感谢评论中的帮助。我最终接受了这里的建议(直接删除ViewAnimator并使用ViewFlipper)。更好的应用程序,但仍然存在同样的问题。我放下了一层LinearLayout容器,它开始正常工作

我假设bhatt4982是正确的,UI深度太大了


bhatt4982,将您的评论作为答案发布,以获得好评。

只是好奇,为什么您直接使用ViewAnimator?ViewFlipper或ViewSwitcher不正是为您这样做的吗?ViewFlipper和ViewSwitcher。。。我会让他们试试看这是否有帮助。。。我对Android还是很陌生,所以谢谢你的建议。希望你已经解决了你的问题!但我觉得问题出在ERROR/AndroidRuntime(6561):java.lang.StackOverflower这通常是由于UI层次结构的深度造成的。
09-06 21:36:48.208: ERROR/AndroidRuntime(6561): Uncaught handler: thread main exiting due to uncaught exception
09-06 21:36:48.248: ERROR/AndroidRuntime(6561): java.lang.StackOverflowError
09-06 21:36:48.248: ERROR/AndroidRuntime(6561):     at android.view.ViewGroup.drawChild(ViewGroup.java:1486)
09-06 21:36:48.248: ERROR/AndroidRuntime(6561):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1228)
(many more lines like this)