0

I have an activity that shows the camera preview, and an ImageView of the last image taken.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent">

<ImageView
        android:id="@+id/stitch_preview"
        android:layout_width="fill_parent"
        android:layout_height="128dp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:scaleType="center"
        android:visibility="gone"/>

<SurfaceView
        android:id="@+id/camera_preview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/stitch_preview"/>

Right now the ImageView is fixed to 128dp height. Is difficult to make this view resizable by dragging your finger down on the ImageView.

I've been searching for various hints, but everything I find relates to pulling out a hidden view. I can't seem to find an example of resizing an already visible view.

Tutorial for doing a pull-down "view" in android?

How to resize a custom view programmatically?

4

1 回答 1

1

通过假设您的 ImageView 是可见的,以下步骤可能会帮助您-

1)捏缩放您的 ImageView 或使用 LayoutParams 使用多点触控实际调整您的 imageview 的大小(您可以根据您的标准范围调整 Imageview 的大小)。

2)使用以下代码捕获您的图像视图

ImageView iv=(ImageView)findViewbyId(R.id.ImageView1)

……

iv.setDrawingCacheEnabled(true);
                // Set the layout manually to after resizing or pinch zoom
                iv.layout(0, 0, x, y);
                // Set the quality to high
                iv.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
                // Build the cache, get the bitmap and close the cache
                iv.buildDrawingCache(true);
                Bitmap bmBarChart = gv.toBitmap();

上面的代码将返回给你调整大小的位图图像。

3)现在保存此图像并将其设置为您的 ImageView

我之前已经调整了可见视图的大小,但我的要求与你略有不同

于 2013-06-14T17:08:22.150 回答