Ambrus Tóth
Ambrus Tóth

Reputation: 652

Swipe Refresh Layout and a WebView in a ScrollView

I have a header text and a webView in a LinearLayout in a ScrollView. I want to add a Swipe Refresh Layout, but I don't know where should I place it because I always get errors or the page is not displayed.

<?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>

Upvotes: 0

Views: 456

Answers (1)

Sunny
Sunny

Reputation: 3265

Try this way I hope it will work for you.

<?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>

Upvotes: 2

Related Questions