0

J'essaie d'afficher un bitmap chargé depuis une carte externe vers une image qui occupe tout l'écran. Mon objectif est d'afficher comment il est affiché dans l'application Galerie. J'ai essayé d'utiliser scaletype="center", scaletype="fitXY" avec et sans adjustViewBounds="true" dans la mise en page xml.Affichage d'un bitmap en taille réelle dans l'imageview

Mon xml est comme ça

<ImageView 
    android:layout_width="wrap_content" 
    android:adjustViewBounds="false" 
    android:scaleType="center" 
    android:layout_centerInParent="true" 
    android:layout_height="wrap_content" 
    android:id="@+id/player_imageview" /> 

Par exemple, Voici comment mon application Galerie l'affiche This is how my Gallery app displays it

C'est ainsi que mon application l'affiche This is how my app displays it

Toute aide être apprécié. Merci.

+1

avez-vous essayé match_parent? – XxGoliathusxX

+1

Oui, j'ai. Si j'ajoute "match_parent", l'imageview occupera tout l'écran. Je ne veux pas ça. Je veux qu'il occupe seulement la taille de l'image bitmap source. –

Répondre

0

J'ai pensé répondre à la question moi-même. J'ai parcouru le code source android de l'application Gallery. Link to the layout of Gallery app. Ils avaient intégré leur imageview personnalisée dans AbsoluteLayout. Comme AbsoluteLayout est obsolète, j'ai intégré mon Imageview dans un FrameLayout.

La solution est

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <ImageView 
     android:id="@+id/player_imageview" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#FF000000" /> 
</FrameLayout> 

Cette FrameLayout est placée à l'intérieur d'un RelativeLayout. Ainsi, fixe. Merci. :)

0

Veuillez essayer svp.

<ImageView 
    android:layout_width="wrap_content" 
    android:adjustViewBounds="false" 
    android:scaleType="fitCenter" 
    android:layout_centerInParent="true" 
    android:layout_height="wrap_content" 
    android:id="@+id/player_imageview" /> 
+0

Merci. Mais cela n'a pas fonctionné non plus. J'ai obtenu le même résultat. :( –

+0

ow je vois. S'il vous plaît changer cette ligne 'android: scaleType =" fitCenter "' à ceci: 'android: scaleType =" centerCrop "' –