Webview shows blank screen

本秂侑毒 提交于 2020-01-17 03:05:30

问题


I know the question may be redundant but I've tried many solutions and nothing could have helped me. In my app, once the user is clicking on a button, it transfers the user to another page. On this page I have a Webview, and a button. They are defined in my xml file as follows:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="1" >

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right"
    android:text="Log out"
    android:id="@+id/btLogot" />

    <WebView 
        android:layout_width="fill_parent"
        android:layout_height="0px"
        android:layout_weight="3"
        android:id="@+id/webView"
         />

</LinearLayout> 

In the other hand, I have used WebViewClient() and override it with shouldOverrideUrlLoading(). The problem is, nothing happens. I think my code is alright, but there's something wrong with my xml and weight of my layouts.

So, what's the matter?!


回答1:


your layout_weight is 3 and the while the layout_weight of the button is not defined. Moreover you should remove layout_weight of the LinearLayout ( if you ment weight sum, it's not compulsory anyway)




回答2:


Some people from other discussions said: that you should use Relative Layout with the Webview!

You can try doing this =)



来源:https://stackoverflow.com/questions/20043984/webview-shows-blank-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!