Ily*_*min 17 android android-design-library androiddesignsupport
我用新的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>
Run Code Online (Sandbox Code Playgroud)
我需要在textView中加载html,所以我做:
content.setText(Html.fromHtml(htmlString));
它看起来很奇怪.我的textview放在屏幕的底部.

在我滑动文本后,它开始看起来正常.

我认为textview不仅仅是对这些问题的看法.我尝试使用webview,但它甚至没有显示内容(我认为由于高度计算不正确).所以我需要webview或textview来纠正工作NestedScrollView.
PS如果我设置textview高度dp然后文本看起来正确,但我需要wrap_content高度.
最后我需要使用WebView.Alex Facciorusso回答部分有效,但我遇到了另一个问题.当WebView内容有一些特定的高度,那么我可以看到部分内容,但我不能向下滚动.例:

阅读了很多帖子,以及 WebView 的自定义实现,但我热衷于试验属性并找出对我有用的方法,这就是:
对于NestedScrollView使用属性
android:fillViewport="true"
Run Code Online (Sandbox Code Playgroud)
并对于底层WebView确保您使用高度作为包装
<WebView
android:id="@+id/webview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</WebView>
Run Code Online (Sandbox Code Playgroud)
所以作为伪代码,你有
<NestedScrollView> // height= match_parent
<Parent_layout>//could be Realtive/Linear with height= match_parent
<Some_View></Some_View>
<Some_View></Some_View>
<WebView></WebView> // height= wrap_content
</Parent_layout>
</NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
正如 Mayur Raiyani 所说:此问题已在支持库版本 22.2.1 中解决:code.google.com/p/android/issues/detail ?id=175234 。谢谢大家的解答。
| 归档时间: |
|
| 查看次数: |
14212 次 |
| 最近记录: |