我使用新的
这是我的布局:
android.support.v4.widget.NestedScrollView
,但遇到了问题。这是我的布局:
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7">
<!-- some views inside -->
</RelativeLayout>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="pin"
/>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
>
<WebView
android:id="@+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.v4.widget.NestedScrollView>
我需要在textView中加载html,所以我这样做:
content.setText(Html.fromHtml(htmlString));
但它看起来很奇怪。我的textview位于屏幕底部。
在我滑动文本后,它开始变得正常。
而且我认为textview不是唯一有这些问题的视图。
我尝试使用webview,但它甚至没有显示内容(我认为是由于错误的高度计算)。
因此,我需要webview或textview来正确使用NestedScrollView
。
P.S. 如果我将textview的高度设置为dp
,则文本会正确显示,但我需要wrap_content
的高度。
更新08.07.15
最终我需要使用WebView
。Alex Facciorusso的答案部分有效,但我遇到了另一个问题。当WebView
内容具有特定高度时,我可以看到一部分内容,但无法向下滚动。
例如:
LinearLayout
设置为match_parent
,使用match_parent
和wrap_content
的RelativeLayout
,直接将TextView
放置在NestedScrollView
中。我认为这是一个NestedScrollView
的问题,但我无法意识到哪里出错了。 - IliaEremin