Android WebView the road to the pit of civilization

Source: Internet
Author: User

Scenario One

WebView in the form of head layout added to the Recyclerview, the first time to enter the page, when the page has EditText and click, even like to change pictures, click WebView Any area, will cause webview automatically slide to the top;

Analysis: My WebView in Onpagefinish () the time to re-measure the height, so the click event is likely to be WebView to get the focus to redraw, so think of not let WebView get focus, tried to use

        android:focusable="true"        android:focusableInTouchMode="true

The above code can only solve the WebView sliding to the top problem caused by clicking outside the WebView area, and clicking on the first entry to the WebView will still cause WebView scrolling; Finally, I thought of code android:descendantfocusability= "Blocksdescendants", seemingly perfect solution

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"        xmlns:tools="http://schemas.android.com/tools"        android:layout_width="match_parent"        android:layout_height="match_parent"        android:orientation="vertical"        android:descendantFocusability="blocksDescendants">            <android.support.v7.widget.RecyclerView                android:layout_width="match_parent"                android:layout_height="match_parent"/>    </LinearLayout>

Descendantfocusability Property Description:

    beforeDescendants:viewgroup会优先其子类控件而获取到焦点    afterDescendants:viewgroup只有当其子类控件不需要获取焦点时才获取焦点    blocksDescendants:viewgroup会覆盖子类控件而直接获得焦点
Scenario Two

WebView on Android 5.0 + some phones will cause WebView to flicker when loading GIF images

Workaround View My other article: WebView 5.0+ Flicker and white screen problem perfect solution

Android WebView the road to the pit of civilization

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.