我使用新的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并不是唯一有这些问题的视图。我试过使用webview,但它甚至不能显示内容(我想是因为高度计算不正确)。所以我需要网页视图或文本视图来纠正与NestedScrollView
的工作。
附注:如果我在dp
中设置文本视图高度,那么文本看起来是正确的,但我需要wrap_content
作为高度。
更新08.07.15
最后,我需要使用WebView
。Alex Facciorusso的回答部分有效,但我面临着另一个问题。当WebView
内容有特定的高度时,我可以看到部分内容,但不能向下滚动。示例:
https://stackoverflow.com/questions/30643081
复制相似问题