我想控制android webview放大,使用搜索栏缩小就像pinchzoom一样。我怎样才能做到这一点? Webview文本缩放控制是从API级别14给出的。但我必须从较低的API级别(8)支持它。
答案 0 :(得分:1)
简单,通过使用webView对象,
webView.getSettings().setBuiltInZoomControls(true);
答案 1 :(得分:0)
XML:
<SeekBar
android:id="@+id/zoombar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:max="20"
android:progress="0"/>
活动类:
private SeekBar myZoomBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
....
myZoomBar = (SeekBar)findViewById(R.id.zoombar);
myZoomBar.setMax (100);
....
myZoomBar.setOnSeekBarChangeListener(myZoomBarOnSeekBarChangeListener);
}
private SeekBar.OnSeekBarChangeListener myZoomBarOnSeekBarChangeListener =
new SeekBar.OnSeekBarChangeListener(){
public void onProgressChanged(SeekBar seekBar, int progress,
boolean fromUser) {
webView.setInitialScale(progress); //For initial Zoom
//You can use `setScaleX()` ans `setScaleY()` but you will have to choose proper scale value for `X` and `Y`
}
public void onStartTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
public void onStopTrackingTouch(SeekBar seekBar) {
// TODO Auto-generated method stub
}
};