我想知道如何在运行时向 ScrollView 添加文本。我在 Android Studio 工作。我正在读取一个文件,并将文本行放入 StringBuilder 缓冲区对象中。
现在如何在 ScrollView 中显示文本?我需要使用.AddView吗?
最佳答案
Scrollview是一个单元素容器,这意味着其中只能有一个元素。
A ScrollView is a FrameLayout, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with a complex hierarchy of objects. A child that is often used is a LinearLayout in a vertical orientation, presenting a vertical array of top-level items that the user can scroll through.
因此,您应该在 ScrollView 中添加 LinearLayout 并向其添加 View 。
关于java - 如何在运行时向 ScrollView 添加文本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40444688/