开发者

HTML formatted content in a ScrollView

I'm trying to put together an Android view that has several elements stacked on top of one another. Some of these elements need to have HTML formatting applied, and I plan to stack enough of them that they will run off the screen, requiring a ScrollView. As an example, I would expect the layout to look something like this:

<ScrollView>
    <LinearLayout vertical>
        <TextView />
        <Button />
        <Html />

        <TextView />
        <Button />
        <Html />

        Etc...
    </LinearLayout>
</ScrollView>

The obvious choice up front for the HTML portion is a WebView, since it renders everything exactly as I would want to see it, but the problem is t开发者_运维知识库hat the WebView begins to fall apart when used in a ScrollView. It's difficult to get it to even show up without some manual refreshing.

Given that, what would be the most effective way to display this type of content?


Option #1: As Sameer Segal indicates, use Html.fromHtml() and TextView.

Option #2: Render the whole thing in HTML. There is nothing particularly magic about Android TextView and Button.

Option #3: Choose some other UI model that would eliminate the need for the ScrollView.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜