Frage

Ich habe ein Image (image_view) in einem XML und ich habe das Layout Schwerkraft Satz Zentrum und die Skala Satz center_inside .... aber wenn ich meinen Druck bmp zum image_view passieren, es legt sich auf dem Middle- links auf dem Bildschirm (im Portrait-Modus) ... irgendwelche Ideen auf, dieses Problem zu umgehen?

hier wird mich auf die Bildansicht Einstellung:

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

        imageView.setImageBitmap(bitmap565);

ich komprimieren es auch in einem Ausgangsstrom:

        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();
        }

Danke allen!

    <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"/>

War es hilfreich?

Lösung

Sie können Ihr Problem lösen nur FrameLayout verwenden.

        

Andere Tipps

ImageView Ihr layout_width die auf fill_parent gesetzt, so layout_gravity seine horizontale Position nicht innerhalb der übergeordneten auswirken wird. Versuchen Sie es mit gravity statt layout_gravity oder wrap_content statt fill_parent.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top