Question

J'ai un ImageView (image_view) dans un fichier XML et je l'ensemble de la gravité de la mise en page au centre et l'ensemble de l'échelle à center_inside .... mais quand je passe mon bmp comprimé au image_view, il met sur le moyen ou à gauche de l'écran (en mode portrait) ... toutes les idées sur une solution de contournement?

paramètre ici me est à la vue de l'image:

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

        imageView.setImageBitmap(bitmap565);

compresser aussi dans un flux de sortie:

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

Merci à tous!

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

Était-ce utile?

La solution

vous pouvez résoudre votre problème juste en utilisant FrameLayout.

        

Autres conseils

La ImageView de votre layout_width est réglé sur fill_parent, donc layout_gravity n'affectera pas sa position horizontale dans son parent. Essayez d'utiliser gravity au lieu de layout_gravity ou wrap_content au lieu de fill_parent.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top