我有LinearLayout作为其主布局的活动。在这种布局中,有一个按钮,增加了一个视图(R.layout.motor_block)的主要布局(R.id.layout):捏缩放和平移
LayoutInflater inflater =
(LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View iv = inflater.inflate(R.layout.motor_block, null);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.layout);
rl.addView(iv);
这工作得很好,但是当我添加更多的意见,屏幕会被他们填满,所以我需要一种通过添加平底锅来“扩展”尺寸的方式,这样我就可以浏览所有的视图。 我也想添加缩放。
我试图用的WebView:
RelativeLayout rl = (RelativeLayout) findViewById(R.id.layout);
WebView wv = (WebView) findViewById(R.id.webView1);
wv.getSettings().setSupportZoom(true);
wv.getSettings().setBuiltInZoomControls(true);
wv.getSettings().setUseWideViewPort(true);
wv.getSettings().setLoadWithOverviewMode(true);
wv.getSettings().setDisplayZoomControls(false);
wv.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);
wv.addView(iv);
的意见被添加到它,和平移工程。问题是,当我缩放时,webView会缩放背景,并且视图不会更改大小。
我也尝试了一些自定义视图,但他们不支持带子视图的视图。
完成此操作的最佳方法是什么?
当视图重新调整大小时,他们是否保持相同的距离? – Sochimickox
如果您手动缩放它们,是的,它们会保持相同的边距,但我不确定ScaleGestureDetector。 – noob
这个答案可以应用于平移和缩放gridview吗? –