1

xmlにImageView(image_view)があり、レイアウトの重力をcenterに設定し、スケールをcenter_insideに設定しています...しかし、圧縮されたbmpをimage_viewに渡すと、それが画面(ポートレートモード)...回避策に関するアイデアはありますか?

これが私がそれを画像ビューに設定することです:

        ImageView imageView = (ImageView) findViewById(R.id.image_view);

        imageView.setImageBitmap(bitmap565);

また、出力ストリームで圧縮します。

        try {
            FileOutputStream fos = new FileOutputStream(filepath);

            bitmap565.compress(CompressFormat.JPEG, 90, fos);

            fos.flush();
            fos.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

皆さんありがとう!

    <ImageButton android:id="@+id/ImageButton01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/results" android:layout_gravity="top|center"></ImageButton><ImageView
            android:screenOrientation="portrait"
            android:layout_width="fill_parent"
            android:id="@+id/image_view"
            android:layout_gravity="center" android:layout_weight="1.0" android:layout_height="wrap_content" android:scaleType="centerInside"/>

    <Button
            android:screenOrientation="portrait"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal" android:layout_width="fill_parent" android:textStyle="bold" android:id="@+id/detect_face" android:text="Detect"/>

4

2 に答える 2

1

ImageView'slayout_widthはに設定されてfill_parentいるためlayout_gravity、親内の水平位置には影響しません。gravityの代わりにlayout_gravity、またはのwrap_content代わりに使用してみてくださいfill_parent

于 2010-11-18T19:31:09.730 に答える
1

FrameLayoutを使用するだけで問題を解決できます。

于 2010-11-19T06:09:46.023 に答える