java - 滑动刷新布局和 ScrollView 中的 WebView

标签 java android android-webview android-scrollview swiperefreshlayout

我在 ScrollView 的 LinearLayout 中有一个标题文本和一个 webView。我想添加一个滑动刷新布局,但我不知道应该把它放在哪里,因为总是出错或页面不显示。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

            <TextView
                style="@style/PageTitle"
                android:text="@string/news_in_fazekas" />

            <WebView
                android:id="@+id/newsWebView"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" />

    </LinearLayout>

</ScrollView>

最佳答案

试试这个方法,希望对你有用。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/swiperefresh"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <TextView
                style="@style/PageTitle"
                android:text="@string/news_in_fazekasx" />
            <WebView
                android:id="@+id/newsWebView"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

        </LinearLayout>

    </ScrollView>

</android.support.v4.widget.SwipeRefreshLayout>

关于java - 滑动刷新布局和 ScrollView 中的 WebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52570348/

相关文章:

javascript - 无法将值从 Javascript 文件发送到 Android Activity

java - 调用 Thread.isInterrupted() 的性能成本是多少?

android - 如何在另一个自定义 View 中添加自定义 View ?

android - WebView 的问题...回到以前的 Activity

Android如何将google帐户传递给webview

android - 谷歌眼镜交互声音

javascript - 如果身份验证失败,则退出 android webview

java - 从 C# 迁移到 C++

java - 将 EJB 注入(inject) Eclipselink SessionCustomizer 以提供 Oracle 模式名称

java - Spring Boot @ConditionalOnProperty 不加载 bean