如何显示内置变焦Controlls在Android的web视图 [英] How to show builtin Zoom Controlls in webview in Android
问题描述
可能重复这个[始终显示在WebView中 1 缩放控制但我只是想显示的缩放控件没有必要总是如此。
may be duplicate to this [Always show zoom controls in WebView1 but I just want to display the zoom controls not necessary always.
基本上我有一个列表视图,我这填写在getVIew方法多的WebView。
Basically i have a list View and i fill this with the multiple webview in getVIew Method.
下面是code
public View getView(final int position, View convertView,
ViewGroup parent) {
View vi = convertView;
if (convertView == null) {
vi = inflater.inflate(R.layout.book_reader_list_style, parent,
false);
holder = new ViewHolder();
holder.webView = (WebView) vi.findViewById(R.id.webView1);
WebSettings webSettings = holder.webView.getSettings();
holder.webView.setVerticalScrollBarEnabled(false);
holder.webView.setHorizontalScrollBarEnabled(false);
holder.webView.setVisibility(View.VISIBLE);
webSettings.setLoadWithOverviewMode(true);
webSettings.setUseWideViewPort(false);
webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
webSettings.setLoadWithOverviewMode(true);
holder.webView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Log.i("Webview", "Clicked");
}
});
vi.setTag(holder);
} else {
holder = (ViewHolder) vi.getTag();
}
holder.webView
.loadDataWithBaseURL(
null,
"<!DOCTYPE html><html><body style = \"text-align:center\"><img style=\"border-style:dotted;border-width:5px;border-color:black;\" src= "
+ URLs.get(position)
+ " alt=\"page Not Found\"></body></html>",
"text/html", "UTF-8", null);
return vi;
}
}
class ViewHolder {
WebView webView;
}
和这里是我的XML文件
and here is my XML file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<WebView
android:id="@+id/webView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:scrollbars="none" />
ListView中充满了网页视图很好,但问题是我想要的变焦按钮控制。
listview is filled with webviews nicely but problem is that i want the Zoom button controls.
- 请对我的XML和Java code看看。什么I M做错了吗?
我曾尝试
webSettings.setBuiltInZoomControls(true);
webSettings.setSupportZoom(true);
但仍无法正常工作
but still not working
推荐答案
请的android:点击=FALSE为机器人:可点击=真正的。在网页视图XML。您可以删除可获得焦点或使它们也是如此。
Make android:clickable="false" to android:clickable="true". In your webView XML. You can remove focusable or make them true also
这篇关于如何显示内置变焦Controlls在Android的web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!