设置在web视图相对布局的中心 [英] Setting webview at the center of relative layout

查看:104
本文介绍了设置在web视图相对布局的中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置以下属性的WebView

I am setting following property for webview

    webView.getSettings().setAllowFileAccess(true);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true);

和使用下面的布局。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@color/solid_white"
    android:layout_marginLeft="1dp" android:gravity="center">


     <WebView
        android:id="@+id/MyView"
        android:layout_centerInParent="true"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        >
    </WebView> 

</RelativeLayout>

这布局的片段。查看即将集中垂直的,但它不来集中水平。 我需要做的相对布局的中心设置的WebView?

This layout is for fragment. View is coming centrally vertical but it not coming centrally horizontal. What I need to do to set webview at the center of relative layout?

推荐答案

刚刚尝试这一点:

MyView.getSettings().setLoadWithOverviewMode(true);
MyView.getSettings().setUseWideViewPort(true);

我希望它为你工作。

I hope it works for you.

这篇关于设置在web视图相对布局的中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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