在 TextureView 上拉伸来自相机的图像

Stretched the image from camera on the TextureView

我正在编写一个使用纹理视图上的相机的应用程序。 首先,摄像头很小window,当你点击按钮时应该会拉伸到全屏。

当textureview在全屏模式下没问题。 但是当我设置为 textureview 固定高度时,来自相机的图片被压缩。 如何使图像正确缩放?

按钮点击侦听器

ViewGroup.LayoutParams params = mTextureView.getLayoutParams();
if(!isFullScreen) {
    isFullScreen = true;
    DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);
    params.width = dm.widthPixels;
    params.height = dm.heightPixels;
    mTextureView.setLayoutParams(params);
}else{
    isFullScreen = false;
    params.height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200, getResources().getDisplayMetrics());
    mTextureView.setLayoutParams(params);
}

我使用 nice 库创建了它 https://github.com/umano/AndroidSlidingUpPanel

<com.sothree.slidinguppanel.SlidingUpPanelLayout xmlns:sothree="http://schemas.android.com/apk/res-auto"
    android:id="@+id/sliding_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="bottom"
    sothree:umanoDragView="@+id/dragView"
    sothree:umanoInitialState="collapsed"
    sothree:umanoPanelHeight="200dp"
    sothree:umanoParalaxOffset="0dp">

    <!-- MAIN CONTENT -->
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" />


    <!-- SLIDING LAYOUT -->
    <LinearLayout
        android:id="@+id/dragView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@android:color/black"
        android:clickable="true"
        android:focusable="true"
        android:orientation="vertical">

        <TextureView
            android:id="@+id/texture_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent" />
    </LinearLayout>

</com.sothree.slidinguppanel.SlidingUpPanelLayout>

并为相机滚动添加了视差

 slidingPanel.setPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {
        @Override
        public void onPanelSlide(View panel, float slideOffset) {
            dragView.setPadding(0, (int) (parallaxOffset * slideOffset - parallaxOffset), 0, 0);
        }

        @Override
        public void onPanelExpanded(View panel) {
            Log.i(TAG, "onPanelExpanded");
            resizeBtn.setSelected(true);
        }

        @Override
        public void onPanelCollapsed(View panel) {
            Log.i(TAG, "onPanelCollapsed");
            resizeBtn.setSelected(false);
        }

        @Override
        public void onPanelAnchored(View panel) {
            Log.i(TAG, "onPanelAnchored");
        }

        @Override
        public void onPanelHidden(View panel) {
            Log.i(TAG, "onPanelHidden");
        }
    });
}