Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Webview仅在新设备上全屏显示,在旧设备上不显示_Android_Html_Css_Webview_Fullscreen - Fatal编程技术网

Android Webview仅在新设备上全屏显示,在旧设备上不显示

Android Webview仅在新设备上全屏显示,在旧设备上不显示,android,html,css,webview,fullscreen,Android,Html,Css,Webview,Fullscreen,我不明白为什么,如果我在Nexus5上试用,一切都很好,但如果我在4.2.2 LG P880或4.1.2 Samsung S2等旧款手机上试用,网络视图的内容将不会是全屏的。知道我做错了什么吗? 这是我的代码: @InjectView(R.id.webview) WebView mWebView; @InjectView(R.id.title_textview) TextView title; @Override protected void onCreate(Bundle savedInst

我不明白为什么,如果我在Nexus5上试用,一切都很好,但如果我在4.2.2 LG P880或4.1.2 Samsung S2等旧款手机上试用,网络视图的内容将不会是全屏的。知道我做错了什么吗? 这是我的代码:

@InjectView(R.id.webview) WebView mWebView;
@InjectView(R.id.title_textview)
TextView title;

@Override
protected void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_webview);
    ButterKnife.inject(this);
    Bundle bundle = getIntent().getExtras();

    if(bundle != null){
        String file = "file:///android_asset/webview/";

        if(bundle.getInt("type") == TYPE_TERMS) {
            title.setText(getString(R.string.terns2));
            file += "terms.html";
        }else if(bundle.getInt("type") == TYPE_PRIVACY) {
            title.setText(getString(R.string.privacy_policy2));
            file += "privacy.html";
        }else if(bundle.getInt("type") == TYPE_ATTRIBUTIONS) {
            title.setText(getString(R.string.attributions2));
            file += "attributions.html";
        }else{
            findViewById(R.id.id_bar).setVisibility(View.GONE);
            file = "https://www.facebook.com/PassengerApp";
        }

        mWebView.setInitialScale(1);
        mWebView.getSettings().setLoadWithOverviewMode(true);
        mWebView.getSettings().setUseWideViewPort(true);
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url){
                return false;
            }
        });

        mWebView.loadUrl(file);
    }
}

@Override
public void onBackPressed() {
    super.onBackPressed();
    overridePendingTransition(R.anim.push_right_in, R.anim.push_right_out);
}
XML:

拿出这个:

 mWebView.setInitialScale(1);
 mWebView.getSettings().setLoadWithOverviewMode(true);
 mWebView.getSettings().setUseWideViewPort(true);

并且没有使用css文件,现在它可以工作了。但是如果有人知道如何使用css文件来实现这一点,那就太好了。

我不是100%确定,但我在为我的主页进行抽奖时遇到了一个类似的问题。我发现老款手机/设备的设置“100%”有问题,这就是为什么它们不显示全尺寸。我做了一个媒体查询,以检查什么样的设备试图显示我的莱佛士,只是给了它一个固定的大小。这不是解决这个问题的最好办法。但它对我有用
*{
margin:0;
padding:0;
}

body{
background-color: #f7f7f7;
width:100%;
color: #424446;
font-size: 46px;
line-height: 1.5em;
}

.bg{
background-color: #f7f7f7;
}

.full{
margin: 10px 20px 20px 10px;
position: relative;
width: 100%;
z-index: 2;
}

h1{
color: #424446;
font-size: 80px;
line-height: 1.5em;
text-align: center;
margin: 40px 0;
}

h1.first{
margin: -50px 0 5px 0;
}

h2,h3{
color: #424446;
font-size: 70px;
line-height: 1.5em;
padding: 35px 0 20px;
margin-top: 80px;
margin-bottom: 40px;
}

ol{
padding-left: 1.7em;
}

ul {
margin-top: 100px;
margin-bottom: 100px;
}

ul li{
margin-top: 20px;
padding-left: 25px;
}

.full.front{
background: url("images/logo.png") no-repeat scroll center top transparent;
font-size: 48px;
line-height: 35px;
margin: 100px auto;
padding: 400px 100px 100px;
text-align: center;
width: 440px;
height: 410px;
}

.terms-link{
font-size: 26px;
}

.download-wrapper a{
background: url("images/button.png") no-repeat scroll 0 0 transparent;
color: white;
display: block;
font-size: 45px;
font-weight: bold;
height: 105px;
line-height: 89px;
text-align: center;
text-decoration: none;
text-transform: uppercase;
width: 402px;
margin: 50px auto;
}

.download-wrapper a:active{
background: url("images/button-pressed.png") no-repeat scroll 0 0 transparent;
}    

.download-wrapper{
margin: 30px 0 40px;
}

a{
color: #1C5188;
}
 mWebView.setInitialScale(1);
 mWebView.getSettings().setLoadWithOverviewMode(true);
 mWebView.getSettings().setUseWideViewPort(true);