里面怎么限制Android程序的的WebView [英] How to restrict the WebView inside in android program
本文介绍了里面怎么限制Android程序的的WebView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想限制的WebView
限制
里面的一些像素
这是在 web视图
初始化时宣布。
查看在insertPoint = findViewById(R.id.layout);的WebView网络=新的WebView(本);
web.setBackgroundColor(Color.GRAY);
INT lHeight = 200;
INT lWidth = 200;
((ViewGroup中)在insertPoint).addView(网页,lWidth,lHeight);web.loadUrl(http://www.google.com);
编辑:
全屏拍摄由的WebView
,它不是居住在 200像素* 200像素
。
编辑:
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:工具=http://schemas.android.com/tools
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingBottom会=@扪/ activity_vertical_margin
机器人:paddingLeft =@扪/ activity_horizontal_margin
机器人:paddingRight =@扪/ activity_horizontal_margin
机器人:paddingTop =@扪/ activity_vertical_margin
工具:上下文=。MainActivity
机器人:ID =@ + ID /布局>< / LinearLayout中>
解决方案
您code应该工作,如果你还添加一行:
web.setWebViewClient(新WebViewClient());
否则,你的code将启动浏览器(这是全屏幕)。如果您单击后退,比如你会看到你的灰色框。
i want to restrict webView's
limit
inside some pixels
which is have declared at the time of webView
initialization .
View insertPoint = findViewById(R.id.layout);
WebView web = new WebView(this) ;
web.setBackgroundColor(Color.GRAY);
int lHeight = 200 ;
int lWidth = 200 ;
( (ViewGroup) insertPoint ).addView(web, lWidth, lHeight) ;
web.loadUrl("http://www.google.com");
Edited :
Full Screen is taken by that WebView
, it is not residing inside 200px*200px
.
Edited :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:id="@+id/layout" >
</LinearLayout>
解决方案
Your code should work if you also add the line:
web.setWebViewClient(new WebViewClient());
Otherwise your code will start the browser(which is full screen). If you click BACK for example you should see your gray box.
这篇关于里面怎么限制Android程序的的WebView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文