At the moment I am working on a file browser. Everything works fine with one exception: If the user clicks on an image (jpg, png, bmp, ..), I want the image to be displayed
Add single line code under your image view initialization into your activity and it will solve your problem..
image.setScaleType(ImageView.ScaleType.FIT_XY);
Have u tried set setType in ImageView?
<ImageView
...
android:scaleType="fitXY"
...
/>
you can make a custom dialog for showing images , make a layout for inflating in dialog's setcontentview , take one linear layout with width and height wrap content and imageview with in it with scale property fitxy .
Change your ImageView from this:
<ImageView
android:id="@+id/thumbnail_IMAGEVIEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:contentDescription="@string/icon_DESCRIPTION" />
To this:
<ImageView
android:id="@+id/thumbnail_IMAGEVIEW"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:adjustViewBounds="true" <!-- Here is the thing -->
android:contentDescription="@string/icon_DESCRIPTION" />
Hope this helps.
Use FrameLayout as it's parent rather than RelativeLayout and set to wrap_content and 0 margins.
Try:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity"
android:background="@color/background">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/frameLayout"
android:background="#b2ff7c">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView"
android:src="@drawable/ic_launcher"/>
</FrameLayout>
</RelativeLayout>
The result should be a background the same size as the ImageView.
If this does work. Try modifying this in a custom theme:
<style name="Widget.ImageWell">
<item name="android:background">@android:drawable/panel_picture_frame_background</item>
</style>