如何prevent从滚动到一个web视图滚动视图加载数据之后? [英] How to prevent a scrollview from scrolling to a webview after data is loaded?

查看:136
本文介绍了如何prevent从滚动到一个web视图滚动视图加载数据之后?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个有趣的问题。尽管我不是手动或以编程方式滚动我的看法,我的WebView正在自动数据后滚动到里面加载。

So I have a fascinating problem. Despite the fact that I'm not manually or programmatically scrolling my view, my WebView is being automatically scrolled to after the data inside it loads.

我有一个viewpager一个片段。当我第一次加载寻呼机,它工作正常,一切都显示。但一旦我翻转页的数据负荷和web视图弹出到页的顶部,隐藏在它上面的观点,这是不希望的。

I've got a fragment in a viewpager. When I first load the pager, it works as expected and everything is shown. But once I "flip the page" the data loads and the WebView pops up to the top of the page, hiding the views above it, which is undesirable.

有谁知道如何发生prevent呢?

Does anyone know how to prevent this from happening?

我的布局看起来像这样的:

My layout looks like such:

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

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

        <TextView
            android:id="@+id/article_title"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:layout_marginTop="10dp"
            android:layout_marginBottom="2dp"
            android:text="Some Title"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@color/article_title"
            android:textStyle="bold" />

        <LinearLayout
            android:id="@+id/LL_Seperator"
            android:layout_width="fill_parent"
            android:layout_height="1dp"
            android:layout_marginLeft="10dp"
            android:layout_marginRight="10dp"
            android:layout_marginTop="5dp"
            android:layout_marginBottom="5dp"
            android:background="@color/text"
            android:orientation="horizontal" >
        </LinearLayout>

        <WebView
            android:id="@+id/article_content"
            android:layout_width="match_parent"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/article_link"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="5dp"
            android:layout_marginTop="5dp"
            android:layout_marginRight="10dp"
            android:layout_marginLeft="10dp"
            android:text="View Full Article"
            android:textColor="@color/article_title"
            android:textStyle="bold" />
    </LinearLayout>

</ScrollView>

我也不会放弃重点任何东西。默认情况下,它似乎自动滚动到的WebView它加载后。我如何prevent呢?

I'm also not giving focus to anything. By default, it seems to automatically scroll to the WebView after it has loaded. How do I prevent this?

推荐答案

我有同样的问题,尝试一些想法,有什么终于为我工作小时后,简单地将descendantFocusability属性的滚动型的含的LinearLayout,与值blockDescendants。你的情况:

I had the same problem, after hours of trying several ideas, what finally worked for me was simply adding the "descendantFocusability" attribute to the ScrollView's containing LinearLayout, with the value "blockDescendants". In your case:

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

还没有问题再次发生的时间:)

Haven't had the problem reoccur since :)

这篇关于如何prevent从滚动到一个web视图滚动视图加载数据之后?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆