我有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嗎? –